@riebeckite/plugin-discord-embed 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -82
- package/README_ja.md +74 -74
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
# @riebeckite/plugin-discord-embed
|
|
2
|
-
|
|
3
|
-
Completes each page's `<head>` for Discord link previews.
|
|
4
|
-
|
|
5
|
-
Discord's `Discordbot` reads the shared page's `<head>` metadata to build its
|
|
6
|
-
preview card. The `seo` plugin already emits the shared `og:*` and `twitter:*`
|
|
7
|
-
tags, so this plugin adds only the Discord-specific pieces that are missing:
|
|
8
|
-
|
|
9
|
-
- `<meta name="theme-color">`, which Discord uses for the embed's left border
|
|
10
|
-
color;
|
|
11
|
-
- `og:image:alt` (and optionally `og:image:width` / `og:image:height`).
|
|
12
|
-
|
|
13
|
-
[日本語](./README_ja.md)
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import { defineConfig } from "@riebeckite/core";
|
|
19
|
-
import { discordEmbed } from "@riebeckite/plugin-discord-embed";
|
|
20
|
-
|
|
21
|
-
export default defineConfig({
|
|
22
|
-
// ...
|
|
23
|
-
plugins: [discordEmbed()],
|
|
24
|
-
});
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
| Option | Type | Default | Description |
|
|
30
|
-
| ------ | ---- | ------- | ----------- |
|
|
31
|
-
| `themeColor` | `string` | `"#5865F2"` | Embed accent color. Discord blurple |
|
|
32
|
-
| `imageAlt` | `boolean` | `true` | Emit `og:image:alt` when the entry has an image |
|
|
33
|
-
| `imageDimensions` | `boolean` | `true` | Emit `og:image:width` / `og:image:height` when the entry's image dimensions are known |
|
|
34
|
-
|
|
35
|
-
`themeColor` accepts `#rgb`, `#rgba`, `#rrggbb`, or `#rrggbbaa`.
|
|
36
|
-
|
|
37
|
-
## Frontmatter
|
|
38
|
-
|
|
39
|
-
| Field | Use |
|
|
40
|
-
| ----- | --- |
|
|
41
|
-
| `theme_color` / `themeColor` / `discord_color` | Override the embed color for one entry |
|
|
42
|
-
| `ogImage` / `image` | Mark that the entry has an image, enabling the image tags |
|
|
43
|
-
| `ogImageWidth` / `imageWidth` | Image width |
|
|
44
|
-
| `ogImageHeight` / `imageHeight` | Image height |
|
|
45
|
-
|
|
46
|
-
The color resolves from the frontmatter override first, then the `themeColor`
|
|
47
|
-
option. An invalid frontmatter color records a
|
|
48
|
-
`discord-embed-invalid-color` diagnostic (warning) and falls back to the option
|
|
49
|
-
default.
|
|
50
|
-
|
|
51
|
-
## Emitted tags
|
|
52
|
-
|
|
53
|
-
The `onManifestCreated` hook assigns `entry.headTags` for every entry:
|
|
54
|
-
|
|
55
|
-
```html
|
|
56
|
-
<meta name="theme-color" content="#1ABC9C" />
|
|
57
|
-
<meta property="og:image:alt" content="Article title" />
|
|
58
|
-
<meta property="og:image:width" content="1200" />
|
|
59
|
-
<meta property="og:image:height" content="630" />
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## The site shell renders `headTags`
|
|
63
|
-
|
|
64
|
-
This plugin does not own the `<head>`. It provides
|
|
65
|
-
`ContentManifestEntry.headTags`; whether to render them is the site's decision.
|
|
66
|
-
A site route sets `c.set("headTags", entry.headTags ?? [])`, and
|
|
67
|
-
`app/routes/_renderer.tsx` maps them to `<meta>` / `<link>` / `<script>`.
|
|
68
|
-
See [HonoX Integration](../../../docs/en/honox-integration.md), section
|
|
69
|
-
"Site application contract", for details.
|
|
70
|
-
|
|
71
|
-
## Exports
|
|
72
|
-
|
|
73
|
-
- `discordEmbed(options?)` / `discordEmbedPlugin(options?)` — plugin factory
|
|
74
|
-
- `buildDiscordHeadTags(entry, options, diagnostics)` — build one entry's head
|
|
75
|
-
tags
|
|
76
|
-
- `resolveDiscordEmbedOptions(options?)` — resolve defaults
|
|
77
|
-
- Types: `DiscordEmbedOptions`, `ResolvedDiscordEmbedOptions`
|
|
78
|
-
|
|
79
|
-
## See also
|
|
80
|
-
|
|
81
|
-
- [HonoX Integration](../../../docs/en/honox-integration.md)
|
|
82
|
-
- [Plugin system](../../../docs/en/plugin-
|
|
1
|
+
# @riebeckite/plugin-discord-embed
|
|
2
|
+
|
|
3
|
+
Completes each page's `<head>` for Discord link previews.
|
|
4
|
+
|
|
5
|
+
Discord's `Discordbot` reads the shared page's `<head>` metadata to build its
|
|
6
|
+
preview card. The `seo` plugin already emits the shared `og:*` and `twitter:*`
|
|
7
|
+
tags, so this plugin adds only the Discord-specific pieces that are missing:
|
|
8
|
+
|
|
9
|
+
- `<meta name="theme-color">`, which Discord uses for the embed's left border
|
|
10
|
+
color;
|
|
11
|
+
- `og:image:alt` (and optionally `og:image:width` / `og:image:height`).
|
|
12
|
+
|
|
13
|
+
[日本語](./README_ja.md)
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { defineConfig } from "@riebeckite/core";
|
|
19
|
+
import { discordEmbed } from "@riebeckite/plugin-discord-embed";
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
// ...
|
|
23
|
+
plugins: [discordEmbed()],
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Options
|
|
28
|
+
|
|
29
|
+
| Option | Type | Default | Description |
|
|
30
|
+
| ------ | ---- | ------- | ----------- |
|
|
31
|
+
| `themeColor` | `string` | `"#5865F2"` | Embed accent color. Discord blurple |
|
|
32
|
+
| `imageAlt` | `boolean` | `true` | Emit `og:image:alt` when the entry has an image |
|
|
33
|
+
| `imageDimensions` | `boolean` | `true` | Emit `og:image:width` / `og:image:height` when the entry's image dimensions are known |
|
|
34
|
+
|
|
35
|
+
`themeColor` accepts `#rgb`, `#rgba`, `#rrggbb`, or `#rrggbbaa`.
|
|
36
|
+
|
|
37
|
+
## Frontmatter
|
|
38
|
+
|
|
39
|
+
| Field | Use |
|
|
40
|
+
| ----- | --- |
|
|
41
|
+
| `theme_color` / `themeColor` / `discord_color` | Override the embed color for one entry |
|
|
42
|
+
| `ogImage` / `image` | Mark that the entry has an image, enabling the image tags |
|
|
43
|
+
| `ogImageWidth` / `imageWidth` | Image width |
|
|
44
|
+
| `ogImageHeight` / `imageHeight` | Image height |
|
|
45
|
+
|
|
46
|
+
The color resolves from the frontmatter override first, then the `themeColor`
|
|
47
|
+
option. An invalid frontmatter color records a
|
|
48
|
+
`discord-embed-invalid-color` diagnostic (warning) and falls back to the option
|
|
49
|
+
default.
|
|
50
|
+
|
|
51
|
+
## Emitted tags
|
|
52
|
+
|
|
53
|
+
The `onManifestCreated` hook assigns `entry.headTags` for every entry:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<meta name="theme-color" content="#1ABC9C" />
|
|
57
|
+
<meta property="og:image:alt" content="Article title" />
|
|
58
|
+
<meta property="og:image:width" content="1200" />
|
|
59
|
+
<meta property="og:image:height" content="630" />
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## The site shell renders `headTags`
|
|
63
|
+
|
|
64
|
+
This plugin does not own the `<head>`. It provides
|
|
65
|
+
`ContentManifestEntry.headTags`; whether to render them is the site's decision.
|
|
66
|
+
A site route sets `c.set("headTags", entry.headTags ?? [])`, and
|
|
67
|
+
`app/routes/_renderer.tsx` maps them to `<meta>` / `<link>` / `<script>`.
|
|
68
|
+
See [HonoX Integration](../../../docs/en/framework/honox-integration.md), section
|
|
69
|
+
"Site application contract", for details.
|
|
70
|
+
|
|
71
|
+
## Exports
|
|
72
|
+
|
|
73
|
+
- `discordEmbed(options?)` / `discordEmbedPlugin(options?)` — plugin factory
|
|
74
|
+
- `buildDiscordHeadTags(entry, options, diagnostics)` — build one entry's head
|
|
75
|
+
tags
|
|
76
|
+
- `resolveDiscordEmbedOptions(options?)` — resolve defaults
|
|
77
|
+
- Types: `DiscordEmbedOptions`, `ResolvedDiscordEmbedOptions`
|
|
78
|
+
|
|
79
|
+
## See also
|
|
80
|
+
|
|
81
|
+
- [HonoX Integration](../../../docs/en/framework/honox-integration.md)
|
|
82
|
+
- [Plugin system](../../../docs/en/reference/plugin-api.md)
|
package/README_ja.md
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
# @riebeckite/plugin-discord-embed
|
|
2
|
-
|
|
3
|
-
Discord のリンクプレビュー向けに、各ページの `<head>` を補完するプラグインです。
|
|
4
|
-
|
|
5
|
-
Discord の `Discordbot` は共有されたページの `<head>` メタデータを読んでプレビューカードを組み立てます。
|
|
6
|
-
`seo` プラグインが共通の `og:*` と `twitter:*` を出力するのに対し、このプラグインは Discord 固有の不足分だけを追加します。
|
|
7
|
-
|
|
8
|
-
- 埋め込みの左側ボーダー色に使われる `<meta name="theme-color">`
|
|
9
|
-
- `og:image:alt`(任意で `og:image:width` / `og:image:height`)
|
|
10
|
-
|
|
11
|
-
[English](./README.md)
|
|
12
|
-
|
|
13
|
-
## 設定する
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { defineConfig } from "@riebeckite/core";
|
|
17
|
-
import { discordEmbed } from "@riebeckite/plugin-discord-embed";
|
|
18
|
-
|
|
19
|
-
export default defineConfig({
|
|
20
|
-
// ...
|
|
21
|
-
plugins: [discordEmbed()],
|
|
22
|
-
});
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## オプション
|
|
26
|
-
|
|
27
|
-
| オプション | 型 | 既定値 | 説明 |
|
|
28
|
-
| --- | --- | --- | --- |
|
|
29
|
-
| `themeColor` | `string` | `"#5865F2"` | 埋め込みのアクセントカラー。Discord の blurple |
|
|
30
|
-
| `imageAlt` | `boolean` | `true` | 画像がある記事に `og:image:alt` を出力する |
|
|
31
|
-
| `imageDimensions` | `boolean` | `true` | 画像サイズが分かる記事に `og:image:width` / `og:image:height` を出力する |
|
|
32
|
-
|
|
33
|
-
`themeColor` は `#rgb`、`#rgba`、`#rrggbb`、`#rrggbbaa` のいずれかを受け付けます。
|
|
34
|
-
|
|
35
|
-
## Frontmatter
|
|
36
|
-
|
|
37
|
-
| フィールド | 用途 |
|
|
38
|
-
| --- | --- |
|
|
39
|
-
| `theme_color` / `themeColor` / `discord_color` | この記事だけ埋め込みカラーを上書きする |
|
|
40
|
-
| `ogImage` / `image` | 画像の有無を判定し、`og:image:alt` などを付ける |
|
|
41
|
-
| `ogImageWidth` / `imageWidth` | 画像の幅 |
|
|
42
|
-
| `ogImageHeight` / `imageHeight` | 画像の高さ |
|
|
43
|
-
|
|
44
|
-
色の解決順は、frontmatter の上書き、なければ `themeColor` オプションです。
|
|
45
|
-
frontmatter の色が無効な場合は診断 `discord-embed-invalid-color`(warning)を記録し、オプションの既定値へフォールバックします。
|
|
46
|
-
|
|
47
|
-
## 出力するタグ
|
|
48
|
-
|
|
49
|
-
`onManifestCreated` フックで、すべてのエントリーに `entry.headTags` を設定します。
|
|
50
|
-
|
|
51
|
-
```html
|
|
52
|
-
<meta name="theme-color" content="#1ABC9C" />
|
|
53
|
-
<meta property="og:image:alt" content="記事タイトル" />
|
|
54
|
-
<meta property="og:image:width" content="1200" />
|
|
55
|
-
<meta property="og:image:height" content="630" />
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Site shell が headTags を描画する
|
|
59
|
-
|
|
60
|
-
このプラグインは `<head>` を所有しません。プラグインが提供するのは `ContentManifestEntry.headTags` であり、描画するかどうかは Site が決めます。
|
|
61
|
-
Site の route が `c.set("headTags", entry.headTags ?? [])` を設定し、`app/routes/_renderer.tsx` がそれを `<meta>` / `<link>` / `<script>` に変換します。
|
|
62
|
-
詳しくは [HonoX Integration](../../../docs/ja/honox-integration.md) の "Site Application の拡張 contract" を参照してください。
|
|
63
|
-
|
|
64
|
-
## 主なエクスポート
|
|
65
|
-
|
|
66
|
-
- `discordEmbed(options?)` / `discordEmbedPlugin(options?)`: プラグインを作成する
|
|
67
|
-
- `buildDiscordHeadTags(entry, options, diagnostics)`: エントリーの head タグを組み立てる
|
|
68
|
-
- `resolveDiscordEmbedOptions(options?)`: 既定値を解決する
|
|
69
|
-
- 型: `DiscordEmbedOptions`、`ResolvedDiscordEmbedOptions`
|
|
70
|
-
|
|
71
|
-
## 関連資料
|
|
72
|
-
|
|
73
|
-
- [HonoX Integration](../../../docs/ja/honox-integration.md)
|
|
74
|
-
- [プラグインシステム](../../../docs/ja/plugin-
|
|
1
|
+
# @riebeckite/plugin-discord-embed
|
|
2
|
+
|
|
3
|
+
Discord のリンクプレビュー向けに、各ページの `<head>` を補完するプラグインです。
|
|
4
|
+
|
|
5
|
+
Discord の `Discordbot` は共有されたページの `<head>` メタデータを読んでプレビューカードを組み立てます。
|
|
6
|
+
`seo` プラグインが共通の `og:*` と `twitter:*` を出力するのに対し、このプラグインは Discord 固有の不足分だけを追加します。
|
|
7
|
+
|
|
8
|
+
- 埋め込みの左側ボーダー色に使われる `<meta name="theme-color">`
|
|
9
|
+
- `og:image:alt`(任意で `og:image:width` / `og:image:height`)
|
|
10
|
+
|
|
11
|
+
[English](./README.md)
|
|
12
|
+
|
|
13
|
+
## 設定する
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { defineConfig } from "@riebeckite/core";
|
|
17
|
+
import { discordEmbed } from "@riebeckite/plugin-discord-embed";
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
// ...
|
|
21
|
+
plugins: [discordEmbed()],
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## オプション
|
|
26
|
+
|
|
27
|
+
| オプション | 型 | 既定値 | 説明 |
|
|
28
|
+
| --- | --- | --- | --- |
|
|
29
|
+
| `themeColor` | `string` | `"#5865F2"` | 埋め込みのアクセントカラー。Discord の blurple |
|
|
30
|
+
| `imageAlt` | `boolean` | `true` | 画像がある記事に `og:image:alt` を出力する |
|
|
31
|
+
| `imageDimensions` | `boolean` | `true` | 画像サイズが分かる記事に `og:image:width` / `og:image:height` を出力する |
|
|
32
|
+
|
|
33
|
+
`themeColor` は `#rgb`、`#rgba`、`#rrggbb`、`#rrggbbaa` のいずれかを受け付けます。
|
|
34
|
+
|
|
35
|
+
## Frontmatter
|
|
36
|
+
|
|
37
|
+
| フィールド | 用途 |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `theme_color` / `themeColor` / `discord_color` | この記事だけ埋め込みカラーを上書きする |
|
|
40
|
+
| `ogImage` / `image` | 画像の有無を判定し、`og:image:alt` などを付ける |
|
|
41
|
+
| `ogImageWidth` / `imageWidth` | 画像の幅 |
|
|
42
|
+
| `ogImageHeight` / `imageHeight` | 画像の高さ |
|
|
43
|
+
|
|
44
|
+
色の解決順は、frontmatter の上書き、なければ `themeColor` オプションです。
|
|
45
|
+
frontmatter の色が無効な場合は診断 `discord-embed-invalid-color`(warning)を記録し、オプションの既定値へフォールバックします。
|
|
46
|
+
|
|
47
|
+
## 出力するタグ
|
|
48
|
+
|
|
49
|
+
`onManifestCreated` フックで、すべてのエントリーに `entry.headTags` を設定します。
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<meta name="theme-color" content="#1ABC9C" />
|
|
53
|
+
<meta property="og:image:alt" content="記事タイトル" />
|
|
54
|
+
<meta property="og:image:width" content="1200" />
|
|
55
|
+
<meta property="og:image:height" content="630" />
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Site shell が headTags を描画する
|
|
59
|
+
|
|
60
|
+
このプラグインは `<head>` を所有しません。プラグインが提供するのは `ContentManifestEntry.headTags` であり、描画するかどうかは Site が決めます。
|
|
61
|
+
Site の route が `c.set("headTags", entry.headTags ?? [])` を設定し、`app/routes/_renderer.tsx` がそれを `<meta>` / `<link>` / `<script>` に変換します。
|
|
62
|
+
詳しくは [HonoX Integration](../../../docs/ja/framework/honox-integration.md) の "Site Application の拡張 contract" を参照してください。
|
|
63
|
+
|
|
64
|
+
## 主なエクスポート
|
|
65
|
+
|
|
66
|
+
- `discordEmbed(options?)` / `discordEmbedPlugin(options?)`: プラグインを作成する
|
|
67
|
+
- `buildDiscordHeadTags(entry, options, diagnostics)`: エントリーの head タグを組み立てる
|
|
68
|
+
- `resolveDiscordEmbedOptions(options?)`: 既定値を解決する
|
|
69
|
+
- 型: `DiscordEmbedOptions`、`ResolvedDiscordEmbedOptions`
|
|
70
|
+
|
|
71
|
+
## 関連資料
|
|
72
|
+
|
|
73
|
+
- [HonoX Integration](../../../docs/ja/framework/honox-integration.md)
|
|
74
|
+
- [プラグインシステム](../../../docs/ja/reference/plugin-api.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-discord-embed",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@riebeckite/core": "0.0.
|
|
17
|
+
"@riebeckite/core": "0.0.14"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public"
|