@riebeckite/plugin-archive 0.0.31 → 0.0.33

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 CHANGED
@@ -27,7 +27,9 @@ export default {
27
27
  ## Page types
28
28
 
29
29
  The plugin registers a single Page Type, `archive`, and only while the plugin is
30
- enabled. Routes are generated by the plugin, not by application code.
30
+ enabled. Routes are generated by the plugin, not by application code: the site's
31
+ catch-all content route serves them, so no dedicated application route is
32
+ needed.
31
33
 
32
34
  - `archive`: one listing page per month at `<basePath>/<yyyy>/<mm>`, with
33
35
  additional pages at `<basePath>/<yyyy>/<mm>/page/<n>` when pagination applies.
@@ -42,7 +44,16 @@ Listings are built from `manifest.discoverableEntries`, so unlisted, draft, and
42
44
  scheduled notes never appear. The period title and the previous/next pagination
43
45
  labels follow `site.locale`; set `locale` on the plugin to override it. Japanese
44
46
  and English labels are provided, and the period is formatted through
45
- `Intl.DateTimeFormat` for any locale.
47
+ `Intl.DateTimeFormat` for any locale. Locale tags written with underscores, such
48
+ as `en_US`, are normalized before formatting.
49
+
50
+ Each resolved page also sets `description` and `language`, so the site's
51
+ document frame can render archive SEO metadata and the `lang` attribute without
52
+ recomputing the period.
53
+
54
+ ## Live example
55
+
56
+ [Open the October 2026 archive](/archive/2026/10)
46
57
 
47
58
  ## Options
48
59
 
@@ -55,18 +66,19 @@ and English labels are provided, and the period is formatted through
55
66
 
56
67
  ## Exports
57
68
 
58
- - `archive` / `archivePlugin` — the plugin factory.
69
+ - `archive` / `archive` — the plugin factory.
59
70
  - `resolveArchiveOptions` — resolves options with defaults.
60
71
  - `buildArchiveCollections` — builds the monthly collections for entries.
61
72
  - `archiveDefinitions` — the Core collection definitions used by the plugin.
62
73
  - `renderArchivePage` — renders one archive listing page to HTML.
63
- - `formatArchivePeriod`, `archivePaginationLabels` — locale helpers.
74
+ - `formatArchivePeriod`, `archivePaginationLabels`,
75
+ `buildArchiveDescription` — locale helpers.
64
76
  - `DEFAULT_ARCHIVE_BASE_PATH`, `DEFAULT_ARCHIVE_PAGE_SIZE`,
65
77
  `DEFAULT_ARCHIVE_CLASS_NAME`, `ARCHIVE_COLLECTION_KIND`.
66
78
 
67
79
  ## Notes
68
80
 
69
- The plugin ships no stylesheet; the rendered fragment carries `rb-archive`
70
- classes so a site can style it directly. Set `basePath` to a different prefix if
71
- `/archive` clashes with existing content, and set it to `""` to turn the
72
- generated pages off without removing the plugin.
81
+ The plugin includes a responsive archive stylesheet that uses the active theme's
82
+ color and typography tokens. Set `basePath` to a different prefix if `/archive`
83
+ clashes with existing content, and set it to `""` to turn the generated pages
84
+ off without removing the plugin.
package/README_ja.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  [English](./README.md)
6
6
 
7
- Riebeckite の月別アーカイブ一覧ページです。Core の collection 機構
8
- (`buildContentCollections`) で一覧を組み立てるため、リンク・順序・ページ
9
- ネーションはサイト全体と同じ query パイプラインを再利用します。
7
+ Riebeckite の月別アーカイブ一覧ページを生成するプラグインです。一覧は Core の
8
+ collection 機構(`buildContentCollections`)で組み立てるため、リンク・順序・
9
+ ページネーションはサイト全体と同じクエリパイプラインを再利用します。
10
10
 
11
11
  ## インストール
12
12
 
@@ -26,25 +26,35 @@ export default {
26
26
 
27
27
  ## ページタイプ
28
28
 
29
- `archive` という 1 つの Page Type を登録し、plugin を有効にしている間だけ
30
- ルートを生成します。ルートはアプリケーションコードではなく plugin が生成
31
- します。
29
+ `archive` という 1 つの PageType を登録し、プラグインを有効にしている間だけ
30
+ ルートを生成します。ルートはアプリケーションコードではなくプラグインが生成
31
+ し、サイトのキャッチオールのコンテンツルートが配信します。専用のアプリケーション
32
+ ルートは不要です。
32
33
 
33
34
  - `archive`: `<basePath>/<yyyy>/<mm>` に月ごとの一覧ページを、ページネー
34
35
  ションがある場合は `<basePath>/<yyyy>/<mm>/page/<n>` に追加ページを生成
35
36
  します。
36
37
 
37
- エントリは `published`、`date`、`created` のうち最初に利用できる日付を月単
38
- 位でグループ化します。月は新しい順に並び、各リンクはエントリの解決済み
39
- パーマリンクを使います。
38
+ エントリは `published`、`date`、`created` のうち最初に利用できる日付を月単位
39
+ でグループ化します。月は新しい順に並び、各リンクにはエントリの解決済みパーマ
40
+ リンクを使います。
40
41
 
41
- ## publication と l10n
42
+ ## 公開範囲と言語
42
43
 
43
44
  一覧は `manifest.discoverableEntries` から組み立てるため、unlisted・下書き・
44
45
  スケジュール公開のノートは現れません。期間タイトルと前後ページのラベルは
45
- `site.locale` に従います。plugin の `locale` で上書きできます。日本語と英語
46
+ `site.locale` に従います。プラグインの `locale` で上書きできます。日本語と英語
46
47
  のラベルを用意し、期間は `Intl.DateTimeFormat` で任意のロケール向けに整形し
47
- ます。
48
+ ます。`en_US` のようなアンダースコア区切りのロケールは整形前に正規化しま
49
+ す。
50
+
51
+ 解決したページは `description` と `language` も設定するため、サイトの
52
+ ドキュメントフレームは期間を再計算せずにアーカイブの SEO メタデータと `lang` 属性
53
+ を描画できます。
54
+
55
+ ## 実行例
56
+
57
+ [2026 年 10 月の Archive を開く](/archive/2026/10)
48
58
 
49
59
  ## オプション
50
60
 
@@ -57,18 +67,18 @@ export default {
57
67
 
58
68
  ## エクスポート
59
69
 
60
- - `archive` / `archivePlugin`:plugin ファクトリ。
70
+ - `archive` / `archive`:プラグインファクトリ。
61
71
  - `resolveArchiveOptions`:既定値を適用してオプションを解決します。
62
72
  - `buildArchiveCollections`:エントリから月別 collection を組み立てます。
63
- - `archiveDefinitions`:plugin が使う Core collection 定義。
73
+ - `archiveDefinitions`:プラグインが使う Core collection 定義。
64
74
  - `renderArchivePage`:アーカイブ一覧ページを HTML に描画します。
65
- - `formatArchivePeriod`、`archivePaginationLabels`:ロケール補助関数。
75
+ - `formatArchivePeriod`、`archivePaginationLabels`、
76
+ `buildArchiveDescription`:ロケール補助関数。
66
77
  - `DEFAULT_ARCHIVE_BASE_PATH`、`DEFAULT_ARCHIVE_PAGE_SIZE`、
67
78
  `DEFAULT_ARCHIVE_CLASS_NAME`、`ARCHIVE_COLLECTION_KIND`。
68
79
 
69
80
  ## 補足
70
81
 
71
- スタイルシートは同梱しません。描画フラグメントは `rb-archive` クラスを持つ
72
- ので、サイト側で直接スタイルできます。`/archive` が既存コンテンツと衝突す
73
- る場合は `basePath` を変更し、plugin を残したまま生成ページを止めたい場合は
74
- `""` を設定します。
82
+ プラグインには、有効なテーマの色と書体トークンを使うレスポンシブなアーカイブ
83
+ スタイルが含まれます。`/archive` が既存コンテンツと衝突する場合は `basePath` を
84
+ 変更し、プラグインを残したまま生成ページを止めたい場合は `""` を設定します。
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import type { ArchiveOptions } from "./src/types.js";
2
2
  export { ARCHIVE_COLLECTION_KIND, archiveDefinitions, buildArchiveCollections, } from "./src/collections.js";
3
- export { archivePaginationLabels, formatArchivePeriod } from "./src/locale.js";
3
+ export { archivePaginationLabels, buildArchiveDescription, formatArchivePeriod, } from "./src/locale.js";
4
4
  export { DEFAULT_ARCHIVE_BASE_PATH, DEFAULT_ARCHIVE_CLASS_NAME, DEFAULT_ARCHIVE_PAGE_SIZE, resolveArchiveOptions, } from "./src/options.js";
5
5
  export { renderArchivePage } from "./src/pages.js";
6
6
  export type { ArchiveOptions, ArchivePage, ResolvedArchiveOptions, } from "./src/types.js";
7
7
  export declare const ARCHIVE_PLUGIN_NAME = "archive";
8
8
  export declare function archive(options?: ArchiveOptions): import("@riebeckite/core").RiebeckitePlugin<ArchiveOptions>;
9
- export declare const archivePlugin: typeof archive;
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // index.ts
2
2
  import {
3
+ createStyleAsset,
3
4
  definePlugin
4
5
  } from "@riebeckite/core";
5
6
 
@@ -12,16 +13,26 @@ import {
12
13
  function archivePaginationLabels(locale) {
13
14
  return isJapanese(locale) ? { previous: "前のページ", next: "次のページ" } : { previous: "Previous", next: "Next" };
14
15
  }
16
+ function buildArchiveDescription(siteTitle, period, locale) {
17
+ return isJapanese(locale) ? `${siteTitle} の ${period} の記事一覧です。` : `Posts from ${period} on ${siteTitle}.`;
18
+ }
19
+ function normalizeArchiveLocale(locale) {
20
+ const value = locale?.trim();
21
+ return value ? value.replace(/_/g, "-") : "en-US";
22
+ }
15
23
  function formatArchivePeriod(value, locale) {
16
24
  const match = /^(\d{4})(?:-(\d{1,2}))?$/.exec(value);
17
25
  if (!match) return value;
18
26
  const year = Number(match[1]);
19
27
  const month = match[2] ? Number(match[2]) : null;
20
- const tag = isJapanese(locale) ? "ja-JP" : locale && locale.trim() !== "" ? locale : "en-US";
21
28
  const options = month === null ? { year: "numeric", timeZone: "UTC" } : { year: "numeric", month: "long", timeZone: "UTC" };
22
- return new Intl.DateTimeFormat(tag, options).format(
23
- new Date(Date.UTC(year, (month ?? 1) - 1, 1))
24
- );
29
+ const date = new Date(Date.UTC(year, (month ?? 1) - 1, 1));
30
+ const tag = isJapanese(locale) ? "ja-JP" : normalizeArchiveLocale(locale);
31
+ try {
32
+ return new Intl.DateTimeFormat(tag, options).format(date);
33
+ } catch {
34
+ return new Intl.DateTimeFormat("en-US", options).format(date);
35
+ }
25
36
  }
26
37
  function isJapanese(locale) {
27
38
  return Boolean(locale && /^ja($|[-_])/i.test(locale));
@@ -116,6 +127,9 @@ function archive(options = {}) {
116
127
  return definePlugin({
117
128
  name: ARCHIVE_PLUGIN_NAME,
118
129
  options,
130
+ assets: [
131
+ createStyleAsset("archive", "@riebeckite/plugin-archive/style.css")
132
+ ],
119
133
  validateOptions: validateArchiveOptions,
120
134
  pageTypes: [
121
135
  {
@@ -140,6 +154,8 @@ function archive(options = {}) {
140
154
  type: "archive",
141
155
  pathname: collection.path,
142
156
  title: page.title,
157
+ description: config ? buildArchiveDescription(config.site.title, page.title, locale) : void 0,
158
+ language: normalizeArchiveLocale(locale),
143
159
  body: page.html
144
160
  };
145
161
  }
@@ -147,7 +163,6 @@ function archive(options = {}) {
147
163
  ]
148
164
  });
149
165
  }
150
- var archivePlugin = archive;
151
166
  function resolveLocale(config, options) {
152
167
  return options.locale ?? config?.site.locale ?? "en";
153
168
  }
@@ -180,8 +195,8 @@ export {
180
195
  archive,
181
196
  archiveDefinitions,
182
197
  archivePaginationLabels,
183
- archivePlugin,
184
198
  buildArchiveCollections,
199
+ buildArchiveDescription,
185
200
  formatArchivePeriod,
186
201
  renderArchivePage,
187
202
  resolveArchiveOptions
@@ -2,4 +2,6 @@ export declare function archivePaginationLabels(locale: string | null | undefine
2
2
  previous: string;
3
3
  next: string;
4
4
  };
5
+ export declare function buildArchiveDescription(siteTitle: string, period: string, locale: string | null | undefined): string;
6
+ export declare function normalizeArchiveLocale(locale: string | null | undefined): string;
5
7
  export declare function formatArchivePeriod(value: string, locale: string | null | undefined): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-archive",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,10 +11,11 @@
11
11
  "import": "./dist/index.js",
12
12
  "source": "./index.ts",
13
13
  "default": "./dist/index.js"
14
- }
14
+ },
15
+ "./style.css": "./style.css"
15
16
  },
16
17
  "dependencies": {
17
- "@riebeckite/core": "0.0.31"
18
+ "@riebeckite/core": "0.0.33"
18
19
  },
19
20
  "devDependencies": {
20
21
  "tsx": "^4.22.4"
@@ -26,7 +27,8 @@
26
27
  "LICENSE",
27
28
  "README.md",
28
29
  "README_ja.md",
29
- "dist"
30
+ "dist",
31
+ "style.css"
30
32
  ],
31
33
  "repository": {
32
34
  "type": "git",
@@ -47,7 +49,9 @@
47
49
  "engines": {
48
50
  "node": "^20.19.0 || >=22.12.0"
49
51
  },
50
- "sideEffects": false,
52
+ "sideEffects": [
53
+ "./style.css"
54
+ ],
51
55
  "scripts": {
52
56
  "build": "node ../../../scripts/build_package.mjs",
53
57
  "test": "node --import tsx --test \"test/*.test.ts\""
package/style.css ADDED
@@ -0,0 +1,69 @@
1
+ [data-rr-archive] {
2
+ margin-block: clamp(2rem, 6vw, 4.5rem);
3
+ color: var(--rb-color-ink);
4
+ }
5
+
6
+ [data-rr-archive] .rb-archive__title {
7
+ margin: 0 0 clamp(1.5rem, 4vw, 2.75rem);
8
+ padding-bottom: 0.75rem;
9
+ border-bottom: 2px solid var(--rb-color-accent);
10
+ font-family: var(--rb-font-heading, inherit);
11
+ font-size: clamp(2rem, 1.5rem + 2vw, 3rem);
12
+ line-height: 1.1;
13
+ }
14
+
15
+ [data-rr-archive] .rb-archive__list {
16
+ display: grid;
17
+ gap: 0;
18
+ margin: 0;
19
+ padding: 0;
20
+ border-top: 1px solid var(--rb-color-border);
21
+ list-style: none;
22
+ }
23
+
24
+ [data-rr-archive] .rb-archive__item {
25
+ border-bottom: 1px solid var(--rb-color-border);
26
+ }
27
+
28
+ [data-rr-archive] .rb-archive__link {
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: space-between;
32
+ gap: 1rem;
33
+ padding: 1rem 0.25rem;
34
+ color: var(--rb-color-link, var(--rb-color-accent));
35
+ font-family: var(--rb-font-heading, inherit);
36
+ font-size: 1.1rem;
37
+ font-weight: 650;
38
+ line-height: 1.4;
39
+ text-decoration: none;
40
+ }
41
+
42
+ [data-rr-archive] .rb-archive__link::after {
43
+ flex: none;
44
+ color: var(--rb-color-muted);
45
+ content: "→";
46
+ transition: transform 140ms ease;
47
+ }
48
+
49
+ [data-rr-archive] .rb-archive__link:hover {
50
+ color: var(--rb-color-accent);
51
+ background: var(--rb-color-surface-hover);
52
+ }
53
+
54
+ [data-rr-archive] .rb-archive__link:hover::after {
55
+ transform: translateX(0.25rem);
56
+ }
57
+
58
+ [data-rr-archive] .rb-archive__pagination {
59
+ display: flex;
60
+ flex-wrap: wrap;
61
+ gap: 0.75rem;
62
+ margin-top: 2rem;
63
+ }
64
+
65
+ [data-rr-archive] .rb-archive__pagination .rb-archive__link {
66
+ padding: 0.5rem 0.75rem;
67
+ border: 1px solid var(--rb-color-border-strong);
68
+ font-size: 0.9375rem;
69
+ }