@riebeckite/plugin-permalink 0.0.16 → 0.0.18
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 +4 -4
- package/README_ja.md +17 -17
- package/dist/index.js +7 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -110,13 +110,13 @@ The field name is configurable:
|
|
|
110
110
|
|
|
111
111
|
```ts
|
|
112
112
|
permalink({
|
|
113
|
-
frontmatter: "
|
|
113
|
+
frontmatter: "permalink-id",
|
|
114
114
|
});
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
```md
|
|
118
118
|
---
|
|
119
|
-
|
|
119
|
+
permalink-id: hello-world
|
|
120
120
|
---
|
|
121
121
|
```
|
|
122
122
|
|
|
@@ -961,6 +961,6 @@ permalink({
|
|
|
961
961
|
|
|
962
962
|
# See also
|
|
963
963
|
|
|
964
|
-
- [Plugin guide](../../../docs/
|
|
965
|
-
- [Content system](../../../docs/
|
|
964
|
+
- [Plugin guide](../../../docs/docs/reference/plugin-api.en.md)
|
|
965
|
+
- [Content system](../../../docs/docs/framework/content-system.en.md)
|
|
966
966
|
|
package/README_ja.md
CHANGED
|
@@ -112,13 +112,13 @@ id: hello-world
|
|
|
112
112
|
|
|
113
113
|
```ts
|
|
114
114
|
permalink({
|
|
115
|
-
frontmatter: "
|
|
115
|
+
frontmatter: "permalink-id",
|
|
116
116
|
});
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
```md
|
|
120
120
|
---
|
|
121
|
-
|
|
121
|
+
permalink-id: hello-world
|
|
122
122
|
---
|
|
123
123
|
```
|
|
124
124
|
|
|
@@ -192,7 +192,7 @@ redirect_from:
|
|
|
192
192
|
|
|
193
193
|
として扱われます。
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
設定は次のとおりです。
|
|
196
196
|
|
|
197
197
|
```ts
|
|
198
198
|
permalink({
|
|
@@ -370,7 +370,7 @@ path: {
|
|
|
370
370
|
}
|
|
371
371
|
```
|
|
372
372
|
|
|
373
|
-
|
|
373
|
+
結果は次のとおりです。
|
|
374
374
|
|
|
375
375
|
```text
|
|
376
376
|
/n/hello-world
|
|
@@ -393,7 +393,7 @@ path: {
|
|
|
393
393
|
}
|
|
394
394
|
```
|
|
395
395
|
|
|
396
|
-
|
|
396
|
+
例を示します。
|
|
397
397
|
|
|
398
398
|
```text
|
|
399
399
|
notes/flutter/hello.md
|
|
@@ -437,7 +437,7 @@ index: {
|
|
|
437
437
|
notes/flutter/index.md
|
|
438
438
|
```
|
|
439
439
|
|
|
440
|
-
ID が `hello-world`
|
|
440
|
+
ID が `hello-world` の場合、URL は次のとおりです。
|
|
441
441
|
|
|
442
442
|
| 設定 | URL |
|
|
443
443
|
| --- | --- |
|
|
@@ -494,7 +494,7 @@ canonical URL
|
|
|
494
494
|
|
|
495
495
|
#### 例: frontmatter を組み合わせる
|
|
496
496
|
|
|
497
|
-
|
|
497
|
+
例えば、プロジェクト固有の frontmatter から ID を作る場合は次のとおりです。
|
|
498
498
|
|
|
499
499
|
```md
|
|
500
500
|
---
|
|
@@ -527,7 +527,7 @@ permalink({
|
|
|
527
527
|
});
|
|
528
528
|
```
|
|
529
529
|
|
|
530
|
-
|
|
530
|
+
結果は次のとおりです。
|
|
531
531
|
|
|
532
532
|
```text
|
|
533
533
|
/articles/flutter-42
|
|
@@ -555,7 +555,7 @@ permalink({
|
|
|
555
555
|
});
|
|
556
556
|
```
|
|
557
557
|
|
|
558
|
-
|
|
558
|
+
結果は次のとおりです。
|
|
559
559
|
|
|
560
560
|
```text
|
|
561
561
|
/articles/hello-world
|
|
@@ -578,7 +578,7 @@ https://example.com NG
|
|
|
578
578
|
|
|
579
579
|
両方を指定すると、ID 決定と URL 構築を完全にカスタマイズできます。
|
|
580
580
|
|
|
581
|
-
例えば年別 URL
|
|
581
|
+
例えば年別 URL を作る場合は次のとおりです。
|
|
582
582
|
|
|
583
583
|
```md
|
|
584
584
|
---
|
|
@@ -613,7 +613,7 @@ permalink({
|
|
|
613
613
|
});
|
|
614
614
|
```
|
|
615
615
|
|
|
616
|
-
|
|
616
|
+
結果は次のとおりです。
|
|
617
617
|
|
|
618
618
|
```text
|
|
619
619
|
/articles/2026/riebeckite-permalink
|
|
@@ -690,7 +690,7 @@ permalink({
|
|
|
690
690
|
|
|
691
691
|
frontmatter に手動の permalink がある場合は、通常の ID 解決と path 構築より優先されます。
|
|
692
692
|
|
|
693
|
-
|
|
693
|
+
例えば、次のようになります。
|
|
694
694
|
|
|
695
695
|
```md
|
|
696
696
|
---
|
|
@@ -827,14 +827,14 @@ Custom `resolvePath` の結果も同じ検証を受けます。
|
|
|
827
827
|
|
|
828
828
|
Permalink Plugin はビルド時に衝突を検出します。
|
|
829
829
|
|
|
830
|
-
|
|
830
|
+
対象は次のとおりです。
|
|
831
831
|
|
|
832
832
|
- ID ↔ ID
|
|
833
833
|
- canonical URL ↔ canonical URL
|
|
834
834
|
- canonical URL ↔ リダイレクト
|
|
835
835
|
- リダイレクト ↔ リダイレクト
|
|
836
836
|
|
|
837
|
-
|
|
837
|
+
例えば、次のようになります。
|
|
838
838
|
|
|
839
839
|
```text
|
|
840
840
|
a.md
|
|
@@ -874,7 +874,7 @@ riebeckite inspect content --list
|
|
|
874
874
|
|
|
875
875
|
Permalink Plugin が有効な場合、記事ごとの ID、ID の出典、permalink を確認できます。
|
|
876
876
|
|
|
877
|
-
|
|
877
|
+
例えば、次のようになります。
|
|
878
878
|
|
|
879
879
|
```text
|
|
880
880
|
PATH ID ID SOURCE PERMALINK
|
|
@@ -977,6 +977,6 @@ permalink({
|
|
|
977
977
|
|
|
978
978
|
## 関連資料
|
|
979
979
|
|
|
980
|
-
- [プラグインシステム](../../../docs/
|
|
981
|
-
- [コンテンツシステム](../../../docs/
|
|
980
|
+
- [プラグインシステム](../../../docs/docs/reference/plugin-api.md)
|
|
981
|
+
- [コンテンツシステム](../../../docs/docs/framework/content-system.md)
|
|
982
982
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// index.ts
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import {
|
|
4
|
+
attachErrorPath,
|
|
4
5
|
definePlugin
|
|
5
6
|
} from "@riebeckite/core";
|
|
6
7
|
import { parse } from "yaml";
|
|
@@ -94,7 +95,12 @@ function parseFrontmatter(entry) {
|
|
|
94
95
|
/^(?:\uFEFF)?---\s*\r?\n([\s\S]*?)\r?\n---\s*(?:\r?\n|$)/
|
|
95
96
|
);
|
|
96
97
|
if (!match) return {};
|
|
97
|
-
|
|
98
|
+
let value;
|
|
99
|
+
try {
|
|
100
|
+
value = parse(match[1] ?? "");
|
|
101
|
+
} catch (error) {
|
|
102
|
+
throw attachErrorPath(error, entry.path);
|
|
103
|
+
}
|
|
98
104
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
99
105
|
throw new Error(`Invalid frontmatter object: ${entry.path}`);
|
|
100
106
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-permalink",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"yaml": "^2.9.0",
|
|
18
|
-
"@riebeckite/core": "0.0.
|
|
18
|
+
"@riebeckite/core": "0.0.18"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"tsx": "^4.22.4",
|
|
22
|
-
"@riebeckite/test": "0.0.
|
|
22
|
+
"@riebeckite/test": "0.0.18"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|