@riebeckite/plugin-breadcrumbs 0.0.15 → 0.0.16
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_ja.md +2 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -8
- package/package.json +3 -3
package/README_ja.md
CHANGED
|
@@ -112,7 +112,6 @@ import "@riebeckite/plugin-breadcrumbs/style.css";
|
|
|
112
112
|
- スラッグ階層のみを参照します。frontmatter の並び順や series プラグインの
|
|
113
113
|
順序は意図的に考慮しません。
|
|
114
114
|
|
|
115
|
-
##
|
|
116
|
-
|
|
117
|
-
- [?????????](../../../docs/ja/docs/reference/plugin-api.md)
|
|
115
|
+
## 関連リンク
|
|
118
116
|
|
|
117
|
+
- [プラグイン API](../../../docs/ja/docs/reference/plugin-api.md)
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ export { BREADCRUMBS_ATTRIBUTE, buildBreadcrumbHeadTag, buildBreadcrumbJsonLd, h
|
|
|
5
5
|
export type { BreadcrumbItem, BreadcrumbsOptions, ResolvedBreadcrumbsOptions, } from "./src/types.js";
|
|
6
6
|
export declare const BREADCRUMBS_PLUGIN_NAME = "breadcrumbs";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Public-location breadcrumbs for Riebeckite notes.
|
|
9
9
|
*
|
|
10
|
-
* For every published entry it derives a trail from the note's
|
|
10
|
+
* For every published entry it derives a trail from the note's canonical public location and
|
|
11
11
|
* inserts a `<nav>` at the top of the manifest entry HTML, which is the final
|
|
12
12
|
* rendering source. The hierarchical BreadcrumbList JSON-LD is contributed
|
|
13
13
|
* through `entry.headTags` so the Site shell can render it in the document
|
package/dist/index.js
CHANGED
|
@@ -5,25 +5,40 @@ import {
|
|
|
5
5
|
} from "@riebeckite/core";
|
|
6
6
|
|
|
7
7
|
// src/breadcrumbs.ts
|
|
8
|
-
import {
|
|
8
|
+
import { resolvePublicFolderLocation } from "@riebeckite/core";
|
|
9
9
|
function buildBreadcrumbItems(args) {
|
|
10
10
|
const { manifest, entry, config, homeLabel } = args;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
if (!entry.slug) return [];
|
|
12
|
+
const segments = publicPathSegments(entry.publicLocation.permalink);
|
|
13
13
|
const items = [];
|
|
14
14
|
const homeName = homeLabel || config.site.title;
|
|
15
|
-
if (homeName) items
|
|
15
|
+
if (homeName) pushBreadcrumbItem(items, { name: homeName, url: "/" });
|
|
16
|
+
if (segments.length === 0) return items;
|
|
16
17
|
for (let index = 0; index < segments.length - 1; index++) {
|
|
17
|
-
const
|
|
18
|
-
const location =
|
|
19
|
-
items
|
|
18
|
+
const pathname = `/${segments.slice(0, index + 1).join("/")}`;
|
|
19
|
+
const location = resolvePublicFolderLocation(manifest, pathname);
|
|
20
|
+
pushBreadcrumbItem(items, {
|
|
20
21
|
name: location.type === "content" ? location.entry.title : titleCaseSegment(segments[index]),
|
|
21
22
|
...location.type === "content" ? { url: location.entry.publicLocation.permalink } : location.type === "generated" ? { url: location.pathname } : {}
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
items
|
|
25
|
+
pushBreadcrumbItem(items, {
|
|
26
|
+
name: entry.title,
|
|
27
|
+
url: entry.publicLocation.permalink
|
|
28
|
+
});
|
|
25
29
|
return items;
|
|
26
30
|
}
|
|
31
|
+
function pushBreadcrumbItem(items, item) {
|
|
32
|
+
const previous = items.at(-1);
|
|
33
|
+
if (previous?.name === item.name) {
|
|
34
|
+
items[items.length - 1] = item;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
items.push(item);
|
|
38
|
+
}
|
|
39
|
+
function publicPathSegments(permalink) {
|
|
40
|
+
return permalink.split("/").filter(Boolean);
|
|
41
|
+
}
|
|
27
42
|
function titleCaseSegment(segment) {
|
|
28
43
|
return segment.length === 0 ? segment : segment.charAt(0).toUpperCase() + segment.slice(1);
|
|
29
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-breadcrumbs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
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.
|
|
18
|
+
"@riebeckite/core": "0.0.16"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"tsx": "^4.22.4",
|
|
22
|
-
"@riebeckite/test": "0.0.
|
|
22
|
+
"@riebeckite/test": "0.0.16"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|