@riebeckite/plugin-related-posts 0.0.19 → 0.0.21
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 +20 -12
- package/README_ja.md +11 -12
- package/dist/index.js +4 -0
- package/dist/src/types.d.ts +1 -0
- package/package.json +3 -3
- package/style.css +3 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ section to the `article.footer` Slot. No client-side JavaScript is required.
|
|
|
6
6
|
|
|
7
7
|
[日本語](./README_ja.md)
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Recommended placement
|
|
10
10
|
|
|
11
11
|
`relatedPosts()` reads the manifest's content graph and scores every other
|
|
12
12
|
published entry against the current one:
|
|
@@ -25,7 +25,7 @@ The plugin contributes the section to each manifest entry's `article.footer`
|
|
|
25
25
|
Slot. The Site decides where to render that Slot, so the section appears on
|
|
26
26
|
generated pages and in feeds when the standard article footer is used.
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Quick Start
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
31
|
import { defineConfig } from "@riebeckite/core";
|
|
@@ -37,26 +37,34 @@ export default defineConfig({
|
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
##
|
|
40
|
+
## Advanced customization
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
The Site can place the public server-rendered component anywhere. Set
|
|
43
|
+
`render: false` first to prevent the automatic `article.footer` contribution;
|
|
44
|
+
ranking and publication filtering remain available through the public helpers.
|
|
45
45
|
|
|
46
46
|
```tsx
|
|
47
|
-
import
|
|
47
|
+
import {
|
|
48
|
+
buildRelatedPosts,
|
|
49
|
+
RelatedPosts,
|
|
50
|
+
resolveRelatedPostsOptions,
|
|
51
|
+
} from "@riebeckite/plugin-related-posts";
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
const options = resolveRelatedPostsOptions({ render: false });
|
|
54
|
+
const entries = buildRelatedPosts({ manifest, entry, options, config });
|
|
55
|
+
|
|
56
|
+
return <aside><RelatedPosts entries={entries} options={options} /></aside>;
|
|
50
57
|
```
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
The official Starter already renders `article.footer` once. Remove the manual
|
|
60
|
+
component to remove a manual placement. Do not use it alongside automatic
|
|
61
|
+
rendering for the same article.
|
|
55
62
|
|
|
56
63
|
## Options
|
|
57
64
|
|
|
58
65
|
| Option | Type | Default | Description |
|
|
59
66
|
| ------ | ---- | ------- | ----------- |
|
|
67
|
+
| `render` | `boolean` | `true` | Append generated navigation to `article.footer`; set `false` for manual placement |
|
|
60
68
|
| `limit` | `number` | `5` | Maximum number of related entries |
|
|
61
69
|
| `minScore` | `number` | `1` | Minimum score required to be listed |
|
|
62
70
|
| `heading` | `boolean` | `true` | Render the `<h2>` heading |
|
|
@@ -112,4 +120,4 @@ import "@riebeckite/plugin-related-posts/style.css";
|
|
|
112
120
|
|
|
113
121
|
## See also
|
|
114
122
|
|
|
115
|
-
- [Plugin guide](../../../docs/docs/reference/plugin-api.
|
|
123
|
+
- [Plugin guide](../../../docs/docs/reference/plugin-api.md)
|
package/README_ja.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
[English](./README.md)
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## 推奨配置
|
|
11
11
|
|
|
12
12
|
`relatedPosts()` はマニフェストのコンテンツグラフを読み、現在のエントリと
|
|
13
13
|
他の公開エントリを次のシグナルで採点します。
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
記事フッターでこの Slot を描画している場合、生成ページとフィードの両方に
|
|
27
27
|
セクションが反映されます。
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## クイックスタート
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
32
|
import { defineConfig } from "@riebeckite/core";
|
|
@@ -38,26 +38,25 @@ export default defineConfig({
|
|
|
38
38
|
});
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
##
|
|
41
|
+
## 高度なカスタマイズ
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
配置できる、サーバー描画の Hono JSX Component も公開しています。既存の helper
|
|
45
|
-
で entries を計算し、解決済みの options を渡してください。
|
|
43
|
+
Site のレイアウト内で任意の位置に配置できるサーバー描画の Hono JSX Component を公開しています。`render: false` で自動の `article.footer` Slot 追加を止め、既存の helper で entries を計算して解決済み options を渡してください。採点と公開境界のフィルタリングは維持されます。
|
|
46
44
|
|
|
47
45
|
```tsx
|
|
48
|
-
import RelatedPosts from "@riebeckite/plugin-related-posts
|
|
46
|
+
import { buildRelatedPosts, RelatedPosts, resolveRelatedPostsOptions } from "@riebeckite/plugin-related-posts";
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
const options = resolveRelatedPostsOptions({ render: false });
|
|
49
|
+
const entries = buildRelatedPosts({ manifest, entry, options, config });
|
|
50
|
+
return <aside><RelatedPosts entries={entries} options={options} /></aside>;
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
`resolveRelatedPostsOptions()` の戻り値を渡します。Plugin を登録しない場合は
|
|
55
|
-
`style.css` も読み込んでください。
|
|
53
|
+
公式 Starter は `article.footer` を一度描画します。手動配置を消すにはコンポーネントを消します。自動描画を有効にしたまま同じ記事へ手動描画しないでください。
|
|
56
54
|
|
|
57
55
|
## オプション
|
|
58
56
|
|
|
59
57
|
| オプション | 型 | 既定値 | 説明 |
|
|
60
58
|
| ---------- | -- | ------ | ---- |
|
|
59
|
+
| `render` | `boolean` | `true` | `article.footer` への自動追加。手動配置では `false` |
|
|
61
60
|
| `limit` | `number` | `5` | 表示する関連エントリの最大件数 |
|
|
62
61
|
| `minScore` | `number` | `1` | 表示に必要な最小スコア |
|
|
63
62
|
| `heading` | `boolean` | `true` | `<h2>` 見出しを出力する |
|
|
@@ -113,4 +112,4 @@ import "@riebeckite/plugin-related-posts/style.css";
|
|
|
113
112
|
|
|
114
113
|
## 関連リンク
|
|
115
114
|
|
|
116
|
-
- [プラグイン API](../../../docs/docs/reference/plugin-api.md)
|
|
115
|
+
- [プラグイン API](../../../docs/docs/reference/plugin-api.ja.md)
|
package/dist/index.js
CHANGED
|
@@ -142,6 +142,7 @@ function relatedPosts(options = {}) {
|
|
|
142
142
|
options,
|
|
143
143
|
validateOptions: validateRelatedPostsOptions,
|
|
144
144
|
onManifestCreated: (context) => {
|
|
145
|
+
if (options.render === false) return;
|
|
145
146
|
const { manifest } = context;
|
|
146
147
|
for (const entry of manifest.discoverableEntries) {
|
|
147
148
|
if (!isEligibleRelatedEntry(entry, manifest, context.config)) continue;
|
|
@@ -166,6 +167,9 @@ var relatedPostsPlugin = relatedPosts;
|
|
|
166
167
|
function validateRelatedPostsOptions(options) {
|
|
167
168
|
if (!options) return [];
|
|
168
169
|
const issues = [];
|
|
170
|
+
if (options.render !== void 0 && typeof options.render !== "boolean") {
|
|
171
|
+
issues.push({ path: "render", message: "Expected a boolean." });
|
|
172
|
+
}
|
|
169
173
|
if (options.limit !== void 0 && (!Number.isInteger(options.limit) || options.limit < 0)) {
|
|
170
174
|
issues.push({ path: "limit", message: "Expected a non-negative integer." });
|
|
171
175
|
}
|
package/dist/src/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-related-posts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"hono": "^4.12.25",
|
|
25
|
-
"@riebeckite/core": "0.0.
|
|
25
|
+
"@riebeckite/core": "0.0.21"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsx": "^4.22.4",
|
|
29
|
-
"@riebeckite/test": "0.0.
|
|
29
|
+
"@riebeckite/test": "0.0.21"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
package/style.css
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
.rb-related-posts ul {
|
|
24
24
|
display: grid;
|
|
25
|
-
gap: 0
|
|
25
|
+
gap: 0;
|
|
26
26
|
margin: 0;
|
|
27
27
|
padding: 0;
|
|
28
28
|
list-style: none;
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
|
|
31
31
|
.rb-related-posts__item {
|
|
32
32
|
margin: 0;
|
|
33
|
-
padding: 0;
|
|
33
|
+
padding: 0.75rem 0;
|
|
34
|
+
border-bottom: 1px solid var(--rb-related-posts-rule);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
.rb-related-posts__link {
|