@riebeckite/plugin-rename 0.0.12 → 0.0.13
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 +123 -123
- package/README_ja.md +103 -103
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
# @riebeckite/plugin-rename
|
|
2
|
-
|
|
3
|
-
Reduces broken URLs after notes are renamed or moved by turning detected
|
|
4
|
-
renames into permanent redirects on the existing Riebeckite redirect
|
|
5
|
-
machinery.
|
|
6
|
-
|
|
7
|
-
[日本語](./README_ja.md)
|
|
8
|
-
|
|
9
|
-
## Basic usage
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import { defineConfig } from "@riebeckite/core";
|
|
13
|
-
import { renamePlugin } from "@riebeckite/plugin-rename";
|
|
14
|
-
|
|
15
|
-
export default defineConfig({
|
|
16
|
-
plugins: [
|
|
17
|
-
renamePlugin({
|
|
18
|
-
status: 308,
|
|
19
|
-
onUnexpectedRemoval: "warning",
|
|
20
|
-
}),
|
|
21
|
-
],
|
|
22
|
-
});
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
When a note moves, the plugin compares the current routes with the route lock
|
|
26
|
-
saved during the previous build. If it can identify the same note, it records a
|
|
27
|
-
redirect from the old permalink to the new one in `manifest.redirects`, which
|
|
28
|
-
Core already consumes for redirect pages and deploy files.
|
|
29
|
-
|
|
30
|
-
## How it works
|
|
31
|
-
|
|
32
|
-
```text
|
|
33
|
-
current entries (published only)
|
|
34
|
-
│
|
|
35
|
-
▼
|
|
36
|
-
buildRouteLock ──► current RouteLock
|
|
37
|
-
│ │
|
|
38
|
-
│ ▼
|
|
39
|
-
└──────────► diffRoutes(previous, current)
|
|
40
|
-
│
|
|
41
|
-
┌──────────────┴───────────────┐
|
|
42
|
-
▼ ▼
|
|
43
|
-
rename redirects diagnostics
|
|
44
|
-
(merged + chain-collapsed) (ambiguous / removed)
|
|
45
|
-
│
|
|
46
|
-
▼
|
|
47
|
-
manifest.redirects ◄── never overwrites an existing key
|
|
48
|
-
│
|
|
49
|
-
▼
|
|
50
|
-
context.cache "routes.lock"
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Detection precedence is strict and never fuzzy:
|
|
54
|
-
|
|
55
|
-
1. **Explicit identity** — the entry's frontmatter `id` matches a lock route's
|
|
56
|
-
`id`.
|
|
57
|
-
2. **Exact content hash** — `sha256(entry.html)` matches exactly one new route.
|
|
58
|
-
3. Otherwise the route is treated as removed.
|
|
59
|
-
|
|
60
|
-
Multiple matching candidates (or none) produce no redirect. Ambiguous matches
|
|
61
|
-
emit a `rename-ambiguous` diagnostic; unmatched removals emit a diagnostic whose
|
|
62
|
-
severity follows `onUnexpectedRemoval`.
|
|
63
|
-
|
|
64
|
-
## State
|
|
65
|
-
|
|
66
|
-
The plugin never writes files directly. The only cross-build state is the route
|
|
67
|
-
lock, stored through `context.cache` under the key `routes.lock`. The cache is
|
|
68
|
-
created under `<content.dir>/../.riebeckite/cache` and is gitignored, so the
|
|
69
|
-
lock is machine-local and is regenerated from scratch when missing or corrupt.
|
|
70
|
-
|
|
71
|
-
Because the lock is machine-local, the first build on a fresh machine has no
|
|
72
|
-
history and cannot detect a rename that happened before the lock existed.
|
|
73
|
-
|
|
74
|
-
## Options
|
|
75
|
-
|
|
76
|
-
| Option | Type | Default | Description |
|
|
77
|
-
| --- | --- | --- | --- |
|
|
78
|
-
| `enabled` | `boolean` | `true` | Enables rename detection |
|
|
79
|
-
| `status` | `301 \| 302 \| 307 \| 308` | `308` | HTTP status for new rename redirects |
|
|
80
|
-
| `onUnexpectedRemoval` | `"info" \| "warning" \| "error"` | `"warning"` | Severity when a route disappears without rename evidence |
|
|
81
|
-
|
|
82
|
-
## Rules and guarantees
|
|
83
|
-
|
|
84
|
-
- Only entries passing `isPublished` are considered. Private or unpublished
|
|
85
|
-
notes never enter the lock and never produce redirects.
|
|
86
|
-
- Existing `manifest.redirects` keys are never overwritten, so Permalink's
|
|
87
|
-
`redirect_from` always wins.
|
|
88
|
-
- Permanent redirect chains are collapsed transitively (`A → B`, `B → C`
|
|
89
|
-
becomes `A → C`).
|
|
90
|
-
- The lock is deterministic: route keys and redirects are sorted, with no
|
|
91
|
-
timestamps or randomness.
|
|
92
|
-
- Redirects are replayed on every build, so the CLI build and the SSG build
|
|
93
|
-
reproduce the same redirects.
|
|
94
|
-
|
|
95
|
-
## Exports
|
|
96
|
-
|
|
97
|
-
Functions:
|
|
98
|
-
|
|
99
|
-
- `renamePlugin(options?)` / `rename(options?)`
|
|
100
|
-
- `diffRoutes(previous, current, options?)`
|
|
101
|
-
- `buildRouteLock(entries, isPublished)`
|
|
102
|
-
- `collapseRedirects(rules)`
|
|
103
|
-
- `applyRouteRedirects(manifest, rules)`
|
|
104
|
-
- `parseRouteLock(value)`, `emptyRouteLock()`, `hashContent(html)`
|
|
105
|
-
|
|
106
|
-
Types:
|
|
107
|
-
|
|
108
|
-
- `RenameOptions`
|
|
109
|
-
- `RouteLock`, `RouteLockRoute`, `RouteLockRedirect`, `RedirectRule`
|
|
110
|
-
- `DiffRoutesOptions`, `DiffRoutesResult`, `RenameDiagnostic`
|
|
111
|
-
|
|
112
|
-
## Limitations
|
|
113
|
-
|
|
114
|
-
- Git-based rename detection is not implemented. It would require filesystem or
|
|
115
|
-
repository access, which plugin code intentionally avoids. Rename detection
|
|
116
|
-
relies on frontmatter `id` and on exact content hashes only.
|
|
117
|
-
- A rename in which both the `id` is absent and the HTML body changes cannot be
|
|
118
|
-
detected and is reported as an unexpected removal.
|
|
119
|
-
|
|
120
|
-
## See also
|
|
121
|
-
|
|
122
|
-
- [Permalink plugin](../permalink/README.md) — stable URLs and `redirect_from`
|
|
123
|
-
- [Plugin guide](../../../docs/en/plugin-
|
|
1
|
+
# @riebeckite/plugin-rename
|
|
2
|
+
|
|
3
|
+
Reduces broken URLs after notes are renamed or moved by turning detected
|
|
4
|
+
renames into permanent redirects on the existing Riebeckite redirect
|
|
5
|
+
machinery.
|
|
6
|
+
|
|
7
|
+
[日本語](./README_ja.md)
|
|
8
|
+
|
|
9
|
+
## Basic usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { defineConfig } from "@riebeckite/core";
|
|
13
|
+
import { renamePlugin } from "@riebeckite/plugin-rename";
|
|
14
|
+
|
|
15
|
+
export default defineConfig({
|
|
16
|
+
plugins: [
|
|
17
|
+
renamePlugin({
|
|
18
|
+
status: 308,
|
|
19
|
+
onUnexpectedRemoval: "warning",
|
|
20
|
+
}),
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
When a note moves, the plugin compares the current routes with the route lock
|
|
26
|
+
saved during the previous build. If it can identify the same note, it records a
|
|
27
|
+
redirect from the old permalink to the new one in `manifest.redirects`, which
|
|
28
|
+
Core already consumes for redirect pages and deploy files.
|
|
29
|
+
|
|
30
|
+
## How it works
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
current entries (published only)
|
|
34
|
+
│
|
|
35
|
+
▼
|
|
36
|
+
buildRouteLock ──► current RouteLock
|
|
37
|
+
│ │
|
|
38
|
+
│ ▼
|
|
39
|
+
└──────────► diffRoutes(previous, current)
|
|
40
|
+
│
|
|
41
|
+
┌──────────────┴───────────────┐
|
|
42
|
+
▼ ▼
|
|
43
|
+
rename redirects diagnostics
|
|
44
|
+
(merged + chain-collapsed) (ambiguous / removed)
|
|
45
|
+
│
|
|
46
|
+
▼
|
|
47
|
+
manifest.redirects ◄── never overwrites an existing key
|
|
48
|
+
│
|
|
49
|
+
▼
|
|
50
|
+
context.cache "routes.lock"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Detection precedence is strict and never fuzzy:
|
|
54
|
+
|
|
55
|
+
1. **Explicit identity** — the entry's frontmatter `id` matches a lock route's
|
|
56
|
+
`id`.
|
|
57
|
+
2. **Exact content hash** — `sha256(entry.html)` matches exactly one new route.
|
|
58
|
+
3. Otherwise the route is treated as removed.
|
|
59
|
+
|
|
60
|
+
Multiple matching candidates (or none) produce no redirect. Ambiguous matches
|
|
61
|
+
emit a `rename-ambiguous` diagnostic; unmatched removals emit a diagnostic whose
|
|
62
|
+
severity follows `onUnexpectedRemoval`.
|
|
63
|
+
|
|
64
|
+
## State
|
|
65
|
+
|
|
66
|
+
The plugin never writes files directly. The only cross-build state is the route
|
|
67
|
+
lock, stored through `context.cache` under the key `routes.lock`. The cache is
|
|
68
|
+
created under `<content.dir>/../.riebeckite/cache` and is gitignored, so the
|
|
69
|
+
lock is machine-local and is regenerated from scratch when missing or corrupt.
|
|
70
|
+
|
|
71
|
+
Because the lock is machine-local, the first build on a fresh machine has no
|
|
72
|
+
history and cannot detect a rename that happened before the lock existed.
|
|
73
|
+
|
|
74
|
+
## Options
|
|
75
|
+
|
|
76
|
+
| Option | Type | Default | Description |
|
|
77
|
+
| --- | --- | --- | --- |
|
|
78
|
+
| `enabled` | `boolean` | `true` | Enables rename detection |
|
|
79
|
+
| `status` | `301 \| 302 \| 307 \| 308` | `308` | HTTP status for new rename redirects |
|
|
80
|
+
| `onUnexpectedRemoval` | `"info" \| "warning" \| "error"` | `"warning"` | Severity when a route disappears without rename evidence |
|
|
81
|
+
|
|
82
|
+
## Rules and guarantees
|
|
83
|
+
|
|
84
|
+
- Only entries passing `isPublished` are considered. Private or unpublished
|
|
85
|
+
notes never enter the lock and never produce redirects.
|
|
86
|
+
- Existing `manifest.redirects` keys are never overwritten, so Permalink's
|
|
87
|
+
`redirect_from` always wins.
|
|
88
|
+
- Permanent redirect chains are collapsed transitively (`A → B`, `B → C`
|
|
89
|
+
becomes `A → C`).
|
|
90
|
+
- The lock is deterministic: route keys and redirects are sorted, with no
|
|
91
|
+
timestamps or randomness.
|
|
92
|
+
- Redirects are replayed on every build, so the CLI build and the SSG build
|
|
93
|
+
reproduce the same redirects.
|
|
94
|
+
|
|
95
|
+
## Exports
|
|
96
|
+
|
|
97
|
+
Functions:
|
|
98
|
+
|
|
99
|
+
- `renamePlugin(options?)` / `rename(options?)`
|
|
100
|
+
- `diffRoutes(previous, current, options?)`
|
|
101
|
+
- `buildRouteLock(entries, isPublished)`
|
|
102
|
+
- `collapseRedirects(rules)`
|
|
103
|
+
- `applyRouteRedirects(manifest, rules)`
|
|
104
|
+
- `parseRouteLock(value)`, `emptyRouteLock()`, `hashContent(html)`
|
|
105
|
+
|
|
106
|
+
Types:
|
|
107
|
+
|
|
108
|
+
- `RenameOptions`
|
|
109
|
+
- `RouteLock`, `RouteLockRoute`, `RouteLockRedirect`, `RedirectRule`
|
|
110
|
+
- `DiffRoutesOptions`, `DiffRoutesResult`, `RenameDiagnostic`
|
|
111
|
+
|
|
112
|
+
## Limitations
|
|
113
|
+
|
|
114
|
+
- Git-based rename detection is not implemented. It would require filesystem or
|
|
115
|
+
repository access, which plugin code intentionally avoids. Rename detection
|
|
116
|
+
relies on frontmatter `id` and on exact content hashes only.
|
|
117
|
+
- A rename in which both the `id` is absent and the HTML body changes cannot be
|
|
118
|
+
detected and is reported as an unexpected removal.
|
|
119
|
+
|
|
120
|
+
## See also
|
|
121
|
+
|
|
122
|
+
- [Permalink plugin](../permalink/README.md) — stable URLs and `redirect_from`
|
|
123
|
+
- [Plugin guide](../../../docs/en/reference/plugin-api.md)
|
package/README_ja.md
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
# @riebeckite/plugin-rename
|
|
2
|
-
|
|
3
|
-
ノートのリネームや移動で発生するリンク切れを減らすプラグインです。検出したリネームを、Riebeckite が既に持つリダイレクト機構(`manifest.redirects`)に恒久的なリダイレクトとして登録します。
|
|
4
|
-
|
|
5
|
-
[English](./README.md)
|
|
6
|
-
|
|
7
|
-
## 基本的な使い方
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
import { defineConfig } from "@riebeckite/core";
|
|
11
|
-
import { renamePlugin } from "@riebeckite/plugin-rename";
|
|
12
|
-
|
|
13
|
-
export default defineConfig({
|
|
14
|
-
plugins: [
|
|
15
|
-
renamePlugin({
|
|
16
|
-
status: 308,
|
|
17
|
-
onUnexpectedRemoval: "warning",
|
|
18
|
-
}),
|
|
19
|
-
],
|
|
20
|
-
});
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
ノートが移動すると、プラグインは現在のルートと、前回のビルドで保存したルートロックを比較します。同一のノートだと判定できた場合は、旧パーマリンクから新パーマリンクへのリダイレクトを `manifest.redirects` に記録します。Core はこのリダイレクトをリダイレクトページやデプロイ用ファイルとしてそのまま利用します。
|
|
24
|
-
|
|
25
|
-
## 仕組み
|
|
26
|
-
|
|
27
|
-
```text
|
|
28
|
-
現在のエントリ(公開分のみ)
|
|
29
|
-
│
|
|
30
|
-
▼
|
|
31
|
-
buildRouteLock ──► 現在の RouteLock
|
|
32
|
-
│ │
|
|
33
|
-
│ ▼
|
|
34
|
-
└──────────► diffRoutes(前回, 今回)
|
|
35
|
-
│
|
|
36
|
-
┌──────────────┴───────────────┐
|
|
37
|
-
▼ ▼
|
|
38
|
-
リネームのリダイレクト 診断メッセージ
|
|
39
|
-
(統合 + チェーン集約) (曖昧 / 消失)
|
|
40
|
-
│
|
|
41
|
-
▼
|
|
42
|
-
manifest.redirects ◄── 既存キーは上書きしない
|
|
43
|
-
│
|
|
44
|
-
▼
|
|
45
|
-
context.cache "routes.lock"
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
判定の優先順位は厳密で、あいまい一致は行いません。
|
|
49
|
-
|
|
50
|
-
1. **明示的な同一性** — エントリの frontmatter `id` がロック内のルートの `id` と一致する。
|
|
51
|
-
2. **内容ハッシュの完全一致** — `sha256(entry.html)` が新しいルートちょうど 1 件と一致する。
|
|
52
|
-
3. どちらも該当しない場合、そのルートは消失とみなす。
|
|
53
|
-
|
|
54
|
-
候補が複数ある場合、または 1 件もない場合はリダイレクトを作りません。曖昧一致では `rename-ambiguous` 診断を、対応の取れない消失では `onUnexpectedRemoval` に従った重要度の診断を出力します。
|
|
55
|
-
|
|
56
|
-
## 状態の保存
|
|
57
|
-
|
|
58
|
-
プラグインが直接ファイルを書き込むことはありません。ビルドをまたぐ状態はルートロックのみで、`context.cache` の `routes.lock` キーに保存します。キャッシュは `<content.dir>/../.riebeckite/cache` に作られて gitignore の対象なので、ロックはマシンローカルです。存在しない場合や壊れている場合は空のロックから再生成します。
|
|
59
|
-
|
|
60
|
-
ロックがマシンローカルであるため、新しいマシンでの初回ビルドには履歴がなく、ロックが存在する前に起きたリネームは検出できません。
|
|
61
|
-
|
|
62
|
-
## オプション
|
|
63
|
-
|
|
64
|
-
| オプション | 型 | 既定値 | 説明 |
|
|
65
|
-
| --- | --- | --- | --- |
|
|
66
|
-
| `enabled` | `boolean` | `true` | リネーム検出を有効にする |
|
|
67
|
-
| `status` | `301 \| 302 \| 307 \| 308` | `308` | 新規リネームリダイレクトの HTTP ステータス |
|
|
68
|
-
| `onUnexpectedRemoval` | `"info" \| "warning" \| "error"` | `"warning"` | リネームの根拠なくルートが消えたときの重要度 |
|
|
69
|
-
|
|
70
|
-
## ルールと保証
|
|
71
|
-
|
|
72
|
-
- `isPublished` を満たすエントリだけを対象にします。非公開ノートはロックにもリダイレクトにも入りません。
|
|
73
|
-
- 既存の `manifest.redirects` のキーは上書きしません。Permalink の `redirect_from` が常に優先されます。
|
|
74
|
-
- 恒久的なリダイレクトのチェーンは推移的に集約します(`A → B` と `B → C` は `A → C` になる)。
|
|
75
|
-
- ロックは決定的です。ルートキーとリダイレクトをソートし、タイムスタンプや乱数を使いません。
|
|
76
|
-
- リダイレクトは毎ビルドで再適用されるため、CLI ビルドと SSG ビルドが同じリダイレクトを再現します。
|
|
77
|
-
|
|
78
|
-
## エクスポート
|
|
79
|
-
|
|
80
|
-
関数:
|
|
81
|
-
|
|
82
|
-
- `renamePlugin(options?)` / `rename(options?)`
|
|
83
|
-
- `diffRoutes(previous, current, options?)`
|
|
84
|
-
- `buildRouteLock(entries, isPublished)`
|
|
85
|
-
- `collapseRedirects(rules)`
|
|
86
|
-
- `applyRouteRedirects(manifest, rules)`
|
|
87
|
-
- `parseRouteLock(value)`、`emptyRouteLock()`、`hashContent(html)`
|
|
88
|
-
|
|
89
|
-
型:
|
|
90
|
-
|
|
91
|
-
- `RenameOptions`
|
|
92
|
-
- `RouteLock`、`RouteLockRoute`、`RouteLockRedirect`、`RedirectRule`
|
|
93
|
-
- `DiffRoutesOptions`、`DiffRoutesResult`、`RenameDiagnostic`
|
|
94
|
-
|
|
95
|
-
## 制限事項
|
|
96
|
-
|
|
97
|
-
- git によるリネーム検出は実装していません。ファイルシステムやリポジトリへのアクセスが必要であり、プラグインコードは意図的にそれを避けています。リネーム検出は frontmatter `id` と内容ハッシュの完全一致のみに依存します。
|
|
98
|
-
- `id` がなく、本文 HTML も変化したリネームは検出できず、予期しない消失として報告されます。
|
|
99
|
-
|
|
100
|
-
## 関連
|
|
101
|
-
|
|
102
|
-
- [Permalink プラグイン](../permalink/README_ja.md) — 安定した URL と `redirect_from`
|
|
103
|
-
- [プラグインガイド](../../../docs/ja/plugin-
|
|
1
|
+
# @riebeckite/plugin-rename
|
|
2
|
+
|
|
3
|
+
ノートのリネームや移動で発生するリンク切れを減らすプラグインです。検出したリネームを、Riebeckite が既に持つリダイレクト機構(`manifest.redirects`)に恒久的なリダイレクトとして登録します。
|
|
4
|
+
|
|
5
|
+
[English](./README.md)
|
|
6
|
+
|
|
7
|
+
## 基本的な使い方
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { defineConfig } from "@riebeckite/core";
|
|
11
|
+
import { renamePlugin } from "@riebeckite/plugin-rename";
|
|
12
|
+
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
plugins: [
|
|
15
|
+
renamePlugin({
|
|
16
|
+
status: 308,
|
|
17
|
+
onUnexpectedRemoval: "warning",
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
ノートが移動すると、プラグインは現在のルートと、前回のビルドで保存したルートロックを比較します。同一のノートだと判定できた場合は、旧パーマリンクから新パーマリンクへのリダイレクトを `manifest.redirects` に記録します。Core はこのリダイレクトをリダイレクトページやデプロイ用ファイルとしてそのまま利用します。
|
|
24
|
+
|
|
25
|
+
## 仕組み
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
現在のエントリ(公開分のみ)
|
|
29
|
+
│
|
|
30
|
+
▼
|
|
31
|
+
buildRouteLock ──► 現在の RouteLock
|
|
32
|
+
│ │
|
|
33
|
+
│ ▼
|
|
34
|
+
└──────────► diffRoutes(前回, 今回)
|
|
35
|
+
│
|
|
36
|
+
┌──────────────┴───────────────┐
|
|
37
|
+
▼ ▼
|
|
38
|
+
リネームのリダイレクト 診断メッセージ
|
|
39
|
+
(統合 + チェーン集約) (曖昧 / 消失)
|
|
40
|
+
│
|
|
41
|
+
▼
|
|
42
|
+
manifest.redirects ◄── 既存キーは上書きしない
|
|
43
|
+
│
|
|
44
|
+
▼
|
|
45
|
+
context.cache "routes.lock"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
判定の優先順位は厳密で、あいまい一致は行いません。
|
|
49
|
+
|
|
50
|
+
1. **明示的な同一性** — エントリの frontmatter `id` がロック内のルートの `id` と一致する。
|
|
51
|
+
2. **内容ハッシュの完全一致** — `sha256(entry.html)` が新しいルートちょうど 1 件と一致する。
|
|
52
|
+
3. どちらも該当しない場合、そのルートは消失とみなす。
|
|
53
|
+
|
|
54
|
+
候補が複数ある場合、または 1 件もない場合はリダイレクトを作りません。曖昧一致では `rename-ambiguous` 診断を、対応の取れない消失では `onUnexpectedRemoval` に従った重要度の診断を出力します。
|
|
55
|
+
|
|
56
|
+
## 状態の保存
|
|
57
|
+
|
|
58
|
+
プラグインが直接ファイルを書き込むことはありません。ビルドをまたぐ状態はルートロックのみで、`context.cache` の `routes.lock` キーに保存します。キャッシュは `<content.dir>/../.riebeckite/cache` に作られて gitignore の対象なので、ロックはマシンローカルです。存在しない場合や壊れている場合は空のロックから再生成します。
|
|
59
|
+
|
|
60
|
+
ロックがマシンローカルであるため、新しいマシンでの初回ビルドには履歴がなく、ロックが存在する前に起きたリネームは検出できません。
|
|
61
|
+
|
|
62
|
+
## オプション
|
|
63
|
+
|
|
64
|
+
| オプション | 型 | 既定値 | 説明 |
|
|
65
|
+
| --- | --- | --- | --- |
|
|
66
|
+
| `enabled` | `boolean` | `true` | リネーム検出を有効にする |
|
|
67
|
+
| `status` | `301 \| 302 \| 307 \| 308` | `308` | 新規リネームリダイレクトの HTTP ステータス |
|
|
68
|
+
| `onUnexpectedRemoval` | `"info" \| "warning" \| "error"` | `"warning"` | リネームの根拠なくルートが消えたときの重要度 |
|
|
69
|
+
|
|
70
|
+
## ルールと保証
|
|
71
|
+
|
|
72
|
+
- `isPublished` を満たすエントリだけを対象にします。非公開ノートはロックにもリダイレクトにも入りません。
|
|
73
|
+
- 既存の `manifest.redirects` のキーは上書きしません。Permalink の `redirect_from` が常に優先されます。
|
|
74
|
+
- 恒久的なリダイレクトのチェーンは推移的に集約します(`A → B` と `B → C` は `A → C` になる)。
|
|
75
|
+
- ロックは決定的です。ルートキーとリダイレクトをソートし、タイムスタンプや乱数を使いません。
|
|
76
|
+
- リダイレクトは毎ビルドで再適用されるため、CLI ビルドと SSG ビルドが同じリダイレクトを再現します。
|
|
77
|
+
|
|
78
|
+
## エクスポート
|
|
79
|
+
|
|
80
|
+
関数:
|
|
81
|
+
|
|
82
|
+
- `renamePlugin(options?)` / `rename(options?)`
|
|
83
|
+
- `diffRoutes(previous, current, options?)`
|
|
84
|
+
- `buildRouteLock(entries, isPublished)`
|
|
85
|
+
- `collapseRedirects(rules)`
|
|
86
|
+
- `applyRouteRedirects(manifest, rules)`
|
|
87
|
+
- `parseRouteLock(value)`、`emptyRouteLock()`、`hashContent(html)`
|
|
88
|
+
|
|
89
|
+
型:
|
|
90
|
+
|
|
91
|
+
- `RenameOptions`
|
|
92
|
+
- `RouteLock`、`RouteLockRoute`、`RouteLockRedirect`、`RedirectRule`
|
|
93
|
+
- `DiffRoutesOptions`、`DiffRoutesResult`、`RenameDiagnostic`
|
|
94
|
+
|
|
95
|
+
## 制限事項
|
|
96
|
+
|
|
97
|
+
- git によるリネーム検出は実装していません。ファイルシステムやリポジトリへのアクセスが必要であり、プラグインコードは意図的にそれを避けています。リネーム検出は frontmatter `id` と内容ハッシュの完全一致のみに依存します。
|
|
98
|
+
- `id` がなく、本文 HTML も変化したリネームは検出できず、予期しない消失として報告されます。
|
|
99
|
+
|
|
100
|
+
## 関連
|
|
101
|
+
|
|
102
|
+
- [Permalink プラグイン](../permalink/README_ja.md) — 安定した URL と `redirect_from`
|
|
103
|
+
- [プラグインガイド](../../../docs/ja/reference/plugin-api.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-rename",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
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.13"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"tsx": "^4.22.4"
|