@riebeckite/plugin-related-posts 0.0.14 → 0.0.15

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
@@ -21,8 +21,9 @@ Candidates are sorted by score (descending), then by title, then by slug, and
21
21
  clamped to `limit`. Entries that score below `minScore` are dropped. When no
22
22
  candidate qualifies, the entry's HTML is left untouched.
23
23
 
24
- The plugin updates both `entry.html` and the cached `PostContent.html` that the
25
- content route renders, so the section appears on generated pages and in feeds.
24
+ The plugin appends the section to the manifest entry's HTML. Core synchronizes
25
+ that HTML with the content the route renders, so the section appears on generated
26
+ pages and in feeds.
26
27
 
27
28
  ## Usage
28
29
 
@@ -94,4 +95,5 @@ import "@riebeckite/plugin-related-posts/style.css";
94
95
 
95
96
  ## See also
96
97
 
97
- - [Plugin guide](../../../docs/en/reference/plugin-api.md)
98
+ - [Plugin guide](../../../docs/en/docs/reference/plugin-api.md)
99
+
package/README_ja.md CHANGED
@@ -15,15 +15,15 @@
15
15
  | シグナル | 重み | 意味 |
16
16
  | -------- | ---- | ---- |
17
17
  | 直接リンク | 3 | 現在のエントリが候補へ、または候補が現在のエントリへリンクしている |
18
- | タグの共有 | 共通タグ1件につき2 | 現在のエントリと候補が同じタグを持つ |
19
- | 共引用 | 共通リンク先1件につき1 | 両方のエントリが同じノートへリンクしている |
18
+ | タグの共有 | 共通タグ 1 件につき 2 | 現在のエントリと候補が同じタグを持つ |
19
+ | 共引用 | 共通リンク先 1 件につき 1 | 両方のエントリが同じノートへリンクしている |
20
20
 
21
21
  候補はスコアの降順、同点ならタイトル、さらに同点ならスラッグの順に並べ、
22
22
  `limit` 件に絞ります。`minScore` 未満の候補は除外します。条件を満たす候補が
23
- 1件もない場合、そのエントリの HTML は変更しません。
23
+ 1 件もない場合、そのエントリの HTML は変更しません。
24
24
 
25
- `entry.html` と、コンテンツルートが描画するキャッシュ済みの
26
- `PostContent.html` の両方を更新するため、生成ページとフィードの両方に
25
+ マニフェストエントリの HTML にセクションを追記します。Core がその HTML を
26
+ コンテンツルートの描画 HTML と同期するため、生成ページとフィードの両方に
27
27
  セクションが反映されます。
28
28
 
29
29
  ## 使い方
@@ -96,4 +96,5 @@ import "@riebeckite/plugin-related-posts/style.css";
96
96
 
97
97
  ## ????
98
98
 
99
- - [?????????](../../../docs/ja/reference/plugin-api.md)
99
+ - [?????????](../../../docs/ja/docs/reference/plugin-api.md)
100
+
package/dist/index.d.ts CHANGED
@@ -8,9 +8,8 @@ export declare const RELATED_POSTS_PLUGIN_NAME = "related-posts";
8
8
  * Build-time "related notes" navigation.
9
9
  *
10
10
  * For every published entry it ranks the other entries in the manifest, then
11
- * appends a `<nav>` section to both `entry.html` and the cached
12
- * `PostContent.html` that the content route renders. No client runtime is
13
- * required.
11
+ * appends a `<nav>` section to the manifest entry HTML, which is the final
12
+ * rendering source. No client runtime is required.
14
13
  */
15
14
  export declare function relatedPosts(options?: RelatedPostsOptions): import("@riebeckite/core").RiebeckitePlugin<RelatedPostsOptions>;
16
15
  /** Alias matching the `*Plugin` suffix used by other plugin factories. */
package/dist/index.js CHANGED
@@ -27,9 +27,6 @@ function normalizeClassName(className) {
27
27
  }
28
28
 
29
29
  // src/related.ts
30
- import {
31
- isPublished
32
- } from "@riebeckite/core";
33
30
  var DIRECT_LINK_WEIGHT = 3;
34
31
  var SHARED_TAG_WEIGHT = 2;
35
32
  var CO_CITATION_WEIGHT = 1;
@@ -77,10 +74,11 @@ function buildRelatedPosts(args) {
77
74
  candidates.sort(compareRelatedEntries);
78
75
  return candidates.slice(0, options.limit);
79
76
  }
80
- function isEligibleRelatedEntry(entry, manifest, config) {
77
+ function isEligibleRelatedEntry(entry, manifest, _config) {
81
78
  if (manifest.redirects.has(entry.permalink)) return false;
82
- if (config) return isPublished(config, entry.frontmatter);
83
- return entry.frontmatter.private !== true && entry.frontmatter.draft !== true && entry.frontmatter.publish !== false;
79
+ return manifest.discoverableEntries.some(
80
+ (candidate) => candidate.slug === entry.slug
81
+ );
84
82
  }
85
83
  function compareRelatedEntries(a, b) {
86
84
  if (b.score !== a.score) return b.score - a.score;
@@ -120,17 +118,18 @@ function renderRelatedPosts(entries, options) {
120
118
  var RELATED_POSTS_PLUGIN_NAME = "related-posts";
121
119
  function relatedPosts(options = {}) {
122
120
  const resolved = resolveRelatedPostsOptions(options);
123
- const processed = /* @__PURE__ */ new Map();
124
121
  return definePlugin({
125
122
  name: RELATED_POSTS_PLUGIN_NAME,
123
+ processedContentCache: {
124
+ version: "related-posts-v1",
125
+ dependencyMode: "none"
126
+ },
127
+ outputDependencies: [{ type: "global" }],
126
128
  options,
127
129
  validateOptions: validateRelatedPostsOptions,
128
- onPostProcessed: (context) => {
129
- processed.set(context.slug, context.content);
130
- },
131
130
  onManifestCreated: (context) => {
132
131
  const { manifest } = context;
133
- for (const entry of manifest.entries) {
132
+ for (const entry of manifest.discoverableEntries) {
134
133
  if (entry.html.includes(RELATED_POSTS_ATTRIBUTE)) continue;
135
134
  if (!isEligibleRelatedEntry(entry, manifest, context.config)) continue;
136
135
  const related = buildRelatedPosts({
@@ -141,10 +140,7 @@ function relatedPosts(options = {}) {
141
140
  });
142
141
  if (related.length === 0) continue;
143
142
  entry.html = `${entry.html}${renderRelatedPosts(related, resolved)}`;
144
- const content = processed.get(entry.slug);
145
- if (content) content.html = entry.html;
146
143
  }
147
- processed.clear();
148
144
  },
149
145
  assets: [createStyleAsset(RELATED_POSTS_PLUGIN_NAME)]
150
146
  });
@@ -1,4 +1,4 @@
1
- import { type ContentManifest, type ContentManifestEntry, type ResolvedRiebeckiteConfig } from "@riebeckite/core";
1
+ import type { ContentManifest, ContentManifestEntry, ResolvedRiebeckiteConfig } from "@riebeckite/core";
2
2
  import type { RelatedPostsEntry, ResolvedRelatedPostsOptions } from "./types.js";
3
3
  /**
4
4
  * Weights are deterministic constants: the same manifest always produces the
@@ -18,14 +18,14 @@ export type BuildRelatedPostsArgs = {
18
18
  config?: ResolvedRiebeckiteConfig;
19
19
  };
20
20
  /**
21
- * Ranks the published entries related to `entry` using the manifest's content
22
- * graph. Pure build-time computation: it only reads `byTag`, `outgoingLinks`,
23
- * `incomingLinks`, `redirects`, and `bySlug`.
21
+ * Ranks the discoverable entries related to `entry` using the manifest's
22
+ * content graph. Pure build-time computation: it only reads manifest indexes
23
+ * and the Core-resolved publishing view.
24
24
  */
25
25
  export declare function buildRelatedPosts(args: BuildRelatedPostsArgs): RelatedPostsEntry[];
26
26
  /**
27
27
  * An entry may receive a related-posts section (and be offered as a related
28
- * candidate) only when it is published and its canonical permalink is not
29
- * shadowed by a redirect. Unpublished and redirect-only entries are skipped.
28
+ * candidate) only when it is discoverable and its canonical permalink is not
29
+ * shadowed by a redirect. Hidden and redirect-only entries are skipped.
30
30
  */
31
- export declare function isEligibleRelatedEntry(entry: ContentManifestEntry, manifest: ContentManifest, config?: ResolvedRiebeckiteConfig): boolean;
31
+ export declare function isEligibleRelatedEntry(entry: ContentManifestEntry, manifest: ContentManifest, _config?: ResolvedRiebeckiteConfig): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-related-posts",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,11 +15,11 @@
15
15
  "./style.css": "./style.css"
16
16
  },
17
17
  "dependencies": {
18
- "@riebeckite/core": "0.0.14"
18
+ "@riebeckite/core": "0.0.15"
19
19
  },
20
20
  "devDependencies": {
21
21
  "tsx": "^4.22.4",
22
- "@riebeckite/test": "0.0.14"
22
+ "@riebeckite/test": "0.0.15"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"