@riebeckite/plugin-alias 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.
Files changed (3) hide show
  1. package/README.md +91 -91
  2. package/README_ja.md +87 -87
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -1,91 +1,91 @@
1
- # @riebeckite/plugin-alias
2
-
3
- Turns Obsidian `aliases` / `alias` frontmatter into site-local redirect URLs, so a note can be reached through its alternate names without changing its canonical permalink.
4
-
5
- [Japanese](./README_ja.md)
6
-
7
- ## What it does
8
-
9
- When a vault note has frontmatter like
10
-
11
- ```md
12
- ---
13
- title: Old Note
14
- aliases:
15
- - legacy-note
16
- - "old notes"
17
- ---
18
- ```
19
-
20
- the plugin registers redirects such as:
21
-
22
- - `/legacy-note` → the note's canonical permalink
23
- - `/old%20notes` → the note's canonical permalink
24
-
25
- Redirects are written into the build-time manifest and resolved by HonoX at request time. No client-side JavaScript is required.
26
-
27
- ## Setup
28
-
29
- ```ts
30
- import { defineConfig } from "@riebeckite/core";
31
- import { aliasPlugin } from "@riebeckite/plugin-alias";
32
-
33
- export default defineConfig({
34
- // ...
35
- plugins: [aliasPlugin()],
36
- });
37
- ```
38
-
39
- It composes with the `permalink` plugin. `alias` augments already-resolved public locations through `extendContentLocations`, so it never overrides or re-derives the canonical permalink, whatever decided it.
40
-
41
- ```ts
42
- plugins: [permalinkPlugin(), aliasPlugin()],
43
- ```
44
-
45
- ## Options
46
-
47
- | Option | Type | Default | Description |
48
- | --- | --- | --- | --- |
49
- | `status` | `301 \| 302 \| 307 \| 308` | `308` | HTTP status used for generated redirects |
50
-
51
- ## Alias normalization
52
-
53
- An alias is treated as an alternate note name and mapped to a path under the site root:
54
-
55
- - A leading `/` is ignored (`Old` and `/Old` both become `/Old`).
56
- - Path separators are allowed (`archive/Old` → `/archive/Old`).
57
- - Each segment is percent-encoded with the same rules as request paths, so non-ASCII and spaces work as-is.
58
- - An alias that cannot become a URL is skipped with a warning:
59
- - empty, or only `.` / `..` segments
60
- - containing `#`, `?`, or `\`
61
- - containing `//` (an empty segment)
62
- - containing malformed percent escapes
63
-
64
- ## Diagnostics
65
-
66
- | Code | Severity | Meaning |
67
- | --- | --- | --- |
68
- | `alias-invalid` | warning | The alias cannot be converted into a URL path. |
69
- | `alias-collision` | warning | The alias path collides with another note's canonical permalink or an existing redirect. |
70
-
71
- A colliding alias is not registered; the existing path wins.
72
-
73
- ## Limitations
74
-
75
- - Redirects are decided at build time; add or change aliases and rebuild the site.
76
- - SSG does not emit dedicated redirect HTML files. Redirects are resolved by the server (`resolveContentRoute` in HonoX).
77
- - Aliases are not part of the content graph (backlinks); only links written in the Markdown count.
78
-
79
- ## Exports
80
-
81
- - `aliasPlugin(options?)` / `alias(options?)` — the plugin factory
82
- - `resolveAliasPath(alias)` — pure alias-to-path helper (returns `null` when invalid)
83
- - Types: `AliasOptions`, `AliasRedirectStatus`, `ResolvedAliasOptions`
84
-
85
- ## Related
86
-
87
- - [Plugin system](../../../docs/en/plugin-system.md)
88
-
89
- ## See also
90
-
91
- - [Plugin guide](../../../docs/en/plugin-system.md)
1
+ # @riebeckite/plugin-alias
2
+
3
+ Turns Obsidian `aliases` / `alias` frontmatter into site-local redirect URLs, so a note can be reached through its alternate names without changing its canonical permalink.
4
+
5
+ [Japanese](./README_ja.md)
6
+
7
+ ## What it does
8
+
9
+ When a vault note has frontmatter like
10
+
11
+ ```md
12
+ ---
13
+ title: Old Note
14
+ aliases:
15
+ - legacy-note
16
+ - "old notes"
17
+ ---
18
+ ```
19
+
20
+ the plugin registers redirects such as:
21
+
22
+ - `/legacy-note` → the note's canonical permalink
23
+ - `/old%20notes` → the note's canonical permalink
24
+
25
+ Redirects are written into the build-time manifest and resolved by HonoX at request time. No client-side JavaScript is required.
26
+
27
+ ## Setup
28
+
29
+ ```ts
30
+ import { defineConfig } from "@riebeckite/core";
31
+ import { aliasPlugin } from "@riebeckite/plugin-alias";
32
+
33
+ export default defineConfig({
34
+ // ...
35
+ plugins: [aliasPlugin()],
36
+ });
37
+ ```
38
+
39
+ It composes with the `permalink` plugin. `alias` augments already-resolved public locations through `extendContentLocations`, so it never overrides or re-derives the canonical permalink, whatever decided it.
40
+
41
+ ```ts
42
+ plugins: [permalinkPlugin(), aliasPlugin()],
43
+ ```
44
+
45
+ ## Options
46
+
47
+ | Option | Type | Default | Description |
48
+ | --- | --- | --- | --- |
49
+ | `status` | `301 \| 302 \| 307 \| 308` | `308` | HTTP status used for generated redirects |
50
+
51
+ ## Alias normalization
52
+
53
+ An alias is treated as an alternate note name and mapped to a path under the site root:
54
+
55
+ - A leading `/` is ignored (`Old` and `/Old` both become `/Old`).
56
+ - Path separators are allowed (`archive/Old` → `/archive/Old`).
57
+ - Each segment is percent-encoded with the same rules as request paths, so non-ASCII and spaces work as-is.
58
+ - An alias that cannot become a URL is skipped with a warning:
59
+ - empty, or only `.` / `..` segments
60
+ - containing `#`, `?`, or `\`
61
+ - containing `//` (an empty segment)
62
+ - containing malformed percent escapes
63
+
64
+ ## Diagnostics
65
+
66
+ | Code | Severity | Meaning |
67
+ | --- | --- | --- |
68
+ | `alias-invalid` | warning | The alias cannot be converted into a URL path. |
69
+ | `alias-collision` | warning | The alias path collides with another note's canonical permalink or an existing redirect. |
70
+
71
+ A colliding alias is not registered; the existing path wins.
72
+
73
+ ## Limitations
74
+
75
+ - Redirects are decided at build time; add or change aliases and rebuild the site.
76
+ - SSG does not emit dedicated redirect HTML files. Redirects are resolved by the server (`resolveContentRoute` in HonoX).
77
+ - Aliases are not part of the content graph (backlinks); only links written in the Markdown count.
78
+
79
+ ## Exports
80
+
81
+ - `aliasPlugin(options?)` / `alias(options?)` — the plugin factory
82
+ - `resolveAliasPath(alias)` — pure alias-to-path helper (returns `null` when invalid)
83
+ - Types: `AliasOptions`, `AliasRedirectStatus`, `ResolvedAliasOptions`
84
+
85
+ ## Related
86
+
87
+ - [Plugin system](../../../docs/en/reference/plugin-api.md)
88
+
89
+ ## See also
90
+
91
+ - [Plugin guide](../../../docs/en/reference/plugin-api.md)
package/README_ja.md CHANGED
@@ -1,87 +1,87 @@
1
- # @riebeckite/plugin-alias
2
-
3
- Obsidian のフロントマター `aliases`(`alias` も可)を、サイト内のリダイレクト URL に変換するプラグインです。ノートの別名でアクセスできるようにしつつ、正規のパーマリンクは変更しません。
4
-
5
- [English](./README.md)
6
-
7
- ## できること
8
-
9
- Vault のノートが
10
-
11
- ```md
12
- ---
13
- title: Old Note
14
- aliases:
15
- - legacy-note
16
- - "古いノート"
17
- ---
18
- ```
19
-
20
- のようなフロントマターを持つとき、このプラグインは次のようなリダイレクトを生成します。
21
-
22
- - `/legacy-note` → ノートの正規パーマリンク
23
- - `/%E5%8F%A4%E3%81%84%E3%83%8E%E3%83%BC%E3%83%88` → ノートの正規パーマリンク
24
-
25
- リダイレクトはビルド時のマニフェストに登録され、リクエスト時に HonoX が解決します。クライアント側の JavaScript は不要です。
26
-
27
- ## 設定
28
-
29
- ```ts
30
- import { defineConfig } from "@riebeckite/core";
31
- import { aliasPlugin } from "@riebeckite/plugin-alias";
32
-
33
- export default defineConfig({
34
- // ...
35
- plugins: [aliasPlugin()],
36
- });
37
- ```
38
-
39
- `permalink` プラグインと併用できます。`alias` は「解決済みの公開ロケーション」を後から拡張する(`extendContentLocations`)ため、正規パーマリンクがどのように決まっていても、その値を上書きしたり再現したりしません。
40
-
41
- ```ts
42
- plugins: [permalinkPlugin(), aliasPlugin()],
43
- ```
44
-
45
- ## オプション
46
-
47
- | オプション | 型 | 既定値 | 内容 |
48
- | --- | --- | --- | --- |
49
- | `status` | `301 \| 302 \| 307 \| 308` | `308` | 生成するリダイレクトの HTTP ステータス |
50
-
51
- ## エイリアスの正規化
52
-
53
- エイリアスは「ノートの別名」として扱い、サイトルートからのパスに変換します。
54
-
55
- - 先頭の `/` は無視します(`Old` も `/Old` も `/Old` になります)。
56
- - パス区切り `/` による階層を許可します(`archive/Old` → `/archive/Old`)。
57
- - 各セグメントはリクエストパスと同じ規則でパーセントエンコードします。日本語や空白を含む別名もそのまま使えます。
58
- - 次のようなエイリアスは URL にできないためスキップし、警告を出します。
59
- - 空、または `.` / `..` だけのセグメント
60
- - `#`、`?`、`\` を含む
61
- - `//`(空セグメント)を含む
62
- - パーセントエンコードが壊れている
63
-
64
- ## 診断
65
-
66
- | コード | 深刻度 | 内容 |
67
- | --- | --- | --- |
68
- | `alias-invalid` | warning | エイリアスを URL パスに変換できない。 |
69
- | `alias-collision` | warning | エイリアスのパスが、別のノートの正規パーマリンクまたは既存のリダイレクトと衝突している。 |
70
-
71
- 衝突したエイリアスは登録されず、既存のパスが優先されます。
72
-
73
- ## 制限事項
74
-
75
- - リダイレクトはビルド時に確定します。エイリアスの追加・変更はサイトを再ビルドすると反映されます。
76
- - SSG ではリダイレクト専用の HTML ファイルは生成されません。リダイレクトはサーバー(HonoX の `resolveContentRoute`)が解決します。
77
- - エイリアスはコンテンツグラフ(バックリンク)には含まれません。元の Markdown に書かれたリンクだけが対象です。
78
-
79
- ## エクスポート
80
-
81
- - `aliasPlugin(options?)` / `alias(options?)` — プラグインファクトリ
82
- - `resolveAliasPath(alias)` — エイリアスをサイト内パスへ変換する純関数(`null` で無効)
83
- - 型: `AliasOptions`、`AliasRedirectStatus`、`ResolvedAliasOptions`
84
-
85
- ## 関連資料
86
-
87
- - [プラグインシステム](../../../docs/ja/plugin-system.md)
1
+ # @riebeckite/plugin-alias
2
+
3
+ Obsidian のフロントマター `aliases`(`alias` も可)を、サイト内のリダイレクト URL に変換するプラグインです。ノートの別名でアクセスできるようにしつつ、正規のパーマリンクは変更しません。
4
+
5
+ [English](./README.md)
6
+
7
+ ## できること
8
+
9
+ Vault のノートが
10
+
11
+ ```md
12
+ ---
13
+ title: Old Note
14
+ aliases:
15
+ - legacy-note
16
+ - "古いノート"
17
+ ---
18
+ ```
19
+
20
+ のようなフロントマターを持つとき、このプラグインは次のようなリダイレクトを生成します。
21
+
22
+ - `/legacy-note` → ノートの正規パーマリンク
23
+ - `/%E5%8F%A4%E3%81%84%E3%83%8E%E3%83%BC%E3%83%88` → ノートの正規パーマリンク
24
+
25
+ リダイレクトはビルド時のマニフェストに登録され、リクエスト時に HonoX が解決します。クライアント側の JavaScript は不要です。
26
+
27
+ ## 設定
28
+
29
+ ```ts
30
+ import { defineConfig } from "@riebeckite/core";
31
+ import { aliasPlugin } from "@riebeckite/plugin-alias";
32
+
33
+ export default defineConfig({
34
+ // ...
35
+ plugins: [aliasPlugin()],
36
+ });
37
+ ```
38
+
39
+ `permalink` プラグインと併用できます。`alias` は「解決済みの公開ロケーション」を後から拡張する(`extendContentLocations`)ため、正規パーマリンクがどのように決まっていても、その値を上書きしたり再現したりしません。
40
+
41
+ ```ts
42
+ plugins: [permalinkPlugin(), aliasPlugin()],
43
+ ```
44
+
45
+ ## オプション
46
+
47
+ | オプション | 型 | 既定値 | 内容 |
48
+ | --- | --- | --- | --- |
49
+ | `status` | `301 \| 302 \| 307 \| 308` | `308` | 生成するリダイレクトの HTTP ステータス |
50
+
51
+ ## エイリアスの正規化
52
+
53
+ エイリアスは「ノートの別名」として扱い、サイトルートからのパスに変換します。
54
+
55
+ - 先頭の `/` は無視します(`Old` も `/Old` も `/Old` になります)。
56
+ - パス区切り `/` による階層を許可します(`archive/Old` → `/archive/Old`)。
57
+ - 各セグメントはリクエストパスと同じ規則でパーセントエンコードします。日本語や空白を含む別名もそのまま使えます。
58
+ - 次のようなエイリアスは URL にできないためスキップし、警告を出します。
59
+ - 空、または `.` / `..` だけのセグメント
60
+ - `#`、`?`、`\` を含む
61
+ - `//`(空セグメント)を含む
62
+ - パーセントエンコードが壊れている
63
+
64
+ ## 診断
65
+
66
+ | コード | 深刻度 | 内容 |
67
+ | --- | --- | --- |
68
+ | `alias-invalid` | warning | エイリアスを URL パスに変換できない。 |
69
+ | `alias-collision` | warning | エイリアスのパスが、別のノートの正規パーマリンクまたは既存のリダイレクトと衝突している。 |
70
+
71
+ 衝突したエイリアスは登録されず、既存のパスが優先されます。
72
+
73
+ ## 制限事項
74
+
75
+ - リダイレクトはビルド時に確定します。エイリアスの追加・変更はサイトを再ビルドすると反映されます。
76
+ - SSG ではリダイレクト専用の HTML ファイルは生成されません。リダイレクトはサーバー(HonoX の `resolveContentRoute`)が解決します。
77
+ - エイリアスはコンテンツグラフ(バックリンク)には含まれません。元の Markdown に書かれたリンクだけが対象です。
78
+
79
+ ## エクスポート
80
+
81
+ - `aliasPlugin(options?)` / `alias(options?)` — プラグインファクトリ
82
+ - `resolveAliasPath(alias)` — エイリアスをサイト内パスへ変換する純関数(`null` で無効)
83
+ - 型: `AliasOptions`、`AliasRedirectStatus`、`ResolvedAliasOptions`
84
+
85
+ ## 関連資料
86
+
87
+ - [プラグインシステム](../../../docs/ja/reference/plugin-api.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-alias",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,11 +14,11 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@riebeckite/core": "0.0.12"
17
+ "@riebeckite/core": "0.0.13"
18
18
  },
19
19
  "devDependencies": {
20
20
  "tsx": "^4.22.4",
21
- "@riebeckite/test": "0.0.12"
21
+ "@riebeckite/test": "0.0.13"
22
22
  },
23
23
  "publishConfig": {
24
24
  "access": "public"