---
title: "テーマと描画プラグイン"
description: "CSS 変数と Shadow Parts で外観を調整し、プラグインで Markdown の表示を拡張します。"
---

> Documentation Index
> Fetch the complete documentation index at: https://blua.pwp.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# テーマと描画プラグイン

## 外観を調整する

管理画面の **コンポーネント** でテーマ、ボタンの色、角丸を確認してコードをコピーできます。`theme` は `auto`、`light`、`dark` に対応します。直接埋め込む場合は親ページの CSS でも指定できます。

```css
blua-comments {
  --blua-color-primary: #963653;
  --blua-color-primary-ink: white;
  --blua-radius-card: 10px;
}
blua-comments::part(content) {
  line-height: 1.7;
}
blua-comments::part(submit) {
  border-radius: 999px;
}
```

JS ではインスタンスごとの `themeTokens` も使えます。iframe の内容には URL で変数を渡します（例 `&--blua-radius-card=10px`）。`#` を含む色や空白を含むフォント名は `createBluaFrameUrl` でエンコードできます。

## callouts を使う

```js
import { mountBluaComments } from '@blua/embed/register';
import { calloutsPlugin } from '@blua/embed/plugins/callouts';

const thread = mountBluaComments(document.querySelector('#discussion'), {
  endpoint: 'https://blua.example',
  siteKey: 'garden',
  pageKey: 'spring-swallows',
  plugins: [calloutsPlugin],
});
```

あらかじめページに `<div id="discussion"></div>` を配置します。コメントの先頭に `> [!TIP]` と書き、次の行を `> ` で始めて本文を入力します。フレームワークでも同じ `plugins` 配列を使えます。iframe では URL に `plugins=callouts` を指定します。JS で追加したインスタンスは `thread.remove()` で取り外せます。

## プラグインを作る

```ts
import type { BluaRenderPlugin } from '@blua/embed';

export const codeLabels: BluaRenderPlugin = {
  name: 'code-labels',
  enhance(body) {
    for (const node of body.querySelectorAll('code')) node.part.add('inline-code');
  },
};
```

`plugins` に追加すると `::part(inline-code)` で装飾できます。プラグインは無害化済みのコメント DOM に対して配列順に実行されます。例外が出たコメントは元の表示に戻り、`blua:plugin-error` が発生します。サイト管理者が信頼するモジュールを使用してください。

iframe の独自プラグインは管理者が設置します。ゲートウェイの `/embed/plugins/code-labels.js` から同じ `name` のプラグインをデフォルトエクスポートし、`BLUA_FRAME_PLUGINS=code-labels` を設定します。その後 iframe の URL に `plugins=code-labels` を追加します。

Source: https://blua.pwp.sh/docs/ja/embed/themes/
