@riebeckite/plugin-backlinks 0.0.15 → 0.0.17
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 +9 -9
- package/README_ja.md +6 -3
- package/dist/index.js +24 -1
- package/package.json +3 -3
- package/style.css +1 -1
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@ current note.
|
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
`
|
|
11
|
-
|
|
12
|
-
note from the content manifest, keeps only
|
|
13
|
-
|
|
10
|
+
`backlinksPlugin()` appends a footer list of incoming links to the
|
|
11
|
+
`article.footer` body slot. `getPublishedBacklinks()` resolves the incoming
|
|
12
|
+
links of a note from the content manifest, keeps only publicly discoverable
|
|
13
|
+
notes, and returns them sorted in manifest order.
|
|
14
14
|
|
|
15
15
|
Without incoming links (or when none of them are published), the component
|
|
16
16
|
renders nothing.
|
|
@@ -27,10 +27,11 @@ export default defineConfig({
|
|
|
27
27
|
});
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
`backlinksPlugin()`
|
|
31
|
-
`style.css` into the app stylesheet.
|
|
30
|
+
`backlinksPlugin()` adds backlinks for every public entry with published
|
|
31
|
+
incoming links and bundles `style.css` into the app stylesheet. Render the
|
|
32
|
+
`article.footer` body slot in the article layout to display the list.
|
|
32
33
|
|
|
33
|
-
###
|
|
34
|
+
### Custom placement
|
|
34
35
|
|
|
35
36
|
```tsx
|
|
36
37
|
import Backlinks, { getPublishedBacklinks } from "@riebeckite/plugin-backlinks";
|
|
@@ -46,7 +47,6 @@ const backlinks = getPublishedBacklinks({
|
|
|
46
47
|
resolveTitle: getArticleTitle,
|
|
47
48
|
});
|
|
48
49
|
|
|
49
|
-
// ...in your route
|
|
50
50
|
return (
|
|
51
51
|
<Article
|
|
52
52
|
footerContent={<Backlinks backlinks={backlinks} />}
|
|
@@ -56,7 +56,7 @@ return (
|
|
|
56
56
|
|
|
57
57
|
## Component
|
|
58
58
|
|
|
59
|
-
`Backlinks({ backlinks })` renders a `<footer class="article-backlinks">` with
|
|
59
|
+
`Backlinks({ backlinks })` renders a `<footer class="article-backlinks rr-backlinks">` with
|
|
60
60
|
an eyebrow label and a list of links to each backlink's resolved `permalink`.
|
|
61
61
|
|
|
62
62
|
## Exports
|
package/README_ja.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## できること
|
|
8
8
|
|
|
9
|
-
`
|
|
9
|
+
`backlinksPlugin()` はコンテンツマニフェストから被リンクを集め、公開対象のノートだけをマニフェスト順で `article.footer` body slot に追加します。`Backlinks` コンポーネントはその結果をフッターのリンク一覧として描画します。表示対象がなければ何も出力しません。
|
|
10
10
|
|
|
11
11
|
## 設定と配置
|
|
12
12
|
|
|
@@ -20,7 +20,11 @@ export default defineConfig({
|
|
|
20
20
|
});
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
プラグインは公開済みの被リンクがある記事へ自動的に出力を追加します。記事レイアウトで `article.footer` body slot を描画してください。
|
|
24
|
+
|
|
25
|
+
### 独自の配置
|
|
26
|
+
|
|
27
|
+
Plugin が追加する footer ではなく、アプリ側で表示位置を決める場合は、記事ルートなどでマニフェストを取得し、現在の `slug` に対する被リンクを渡してください。
|
|
24
28
|
|
|
25
29
|
```tsx
|
|
26
30
|
import Backlinks, { getPublishedBacklinks } from "@riebeckite/plugin-backlinks";
|
|
@@ -43,4 +47,3 @@ return <Article footerContent={<Backlinks backlinks={items} />} />;
|
|
|
43
47
|
- [プラグインシステム](../../../docs/ja/docs/reference/plugin-api.md)
|
|
44
48
|
- [`@riebeckite/plugin-local-graph`](../local-graph/README_ja.md)
|
|
45
49
|
- [`@riebeckite/plugin-garden-explorer`](../garden-explorer/README_ja.md)
|
|
46
|
-
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// index.ts
|
|
2
|
-
import { definePlugin } from "@riebeckite/core";
|
|
2
|
+
import { appendContentBodySlot, definePlugin } from "@riebeckite/core";
|
|
3
|
+
import { renderToString } from "hono/jsx/dom/server";
|
|
3
4
|
|
|
4
5
|
// components/backlinks.tsx
|
|
5
6
|
import { jsx, jsxs } from "hono/jsx/jsx-runtime";
|
|
@@ -33,6 +34,24 @@ function getPublishedBacklinks(args) {
|
|
|
33
34
|
function backlinksPlugin() {
|
|
34
35
|
return definePlugin({
|
|
35
36
|
name: "backlinks",
|
|
37
|
+
order: 500,
|
|
38
|
+
onManifestCreated: ({ config, manifest }) => {
|
|
39
|
+
if (!config) return;
|
|
40
|
+
for (const entry of manifest.discoverableEntries) {
|
|
41
|
+
const backlinks = getPublishedBacklinks({
|
|
42
|
+
manifest,
|
|
43
|
+
config,
|
|
44
|
+
slug: entry.slug,
|
|
45
|
+
resolveTitle
|
|
46
|
+
});
|
|
47
|
+
if (backlinks.length === 0) continue;
|
|
48
|
+
appendContentBodySlot(
|
|
49
|
+
entry,
|
|
50
|
+
"article.footer",
|
|
51
|
+
renderToString(Backlinks({ backlinks }))
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
36
55
|
assets: [
|
|
37
56
|
{
|
|
38
57
|
pluginName: "backlinks",
|
|
@@ -42,6 +61,10 @@ function backlinksPlugin() {
|
|
|
42
61
|
]
|
|
43
62
|
});
|
|
44
63
|
}
|
|
64
|
+
function resolveTitle(slug, title) {
|
|
65
|
+
if (typeof title === "string" && title.trim()) return title;
|
|
66
|
+
return slug.split("/").at(-1) ?? slug;
|
|
67
|
+
}
|
|
45
68
|
export {
|
|
46
69
|
Backlinks,
|
|
47
70
|
backlinksPlugin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-backlinks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
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.17"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsx": "^4.22.4",
|
|
29
|
-
"@riebeckite/test": "0.0.
|
|
29
|
+
"@riebeckite/test": "0.0.17"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
package/style.css
CHANGED