@lupinum/ginko-content 1.0.0-beta.1 → 1.0.0-beta.2
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 +3 -3
- package/dist/features/agent/agent-markdown.d.ts +1 -0
- package/dist/features/agent/walker.js +7 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/server/agent-markdown.js +4 -1
- package/dist/runtime/server/agent-site.d.ts +2 -0
- package/dist/runtime/server/agent-site.js +11 -0
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
> [!WARNING]
|
|
18
|
-
> Version `1.0.0-beta.
|
|
18
|
+
> Version `1.0.0-beta.2` is a prerelease. Install it from npm's `next`
|
|
19
19
|
> channel. The stable `0.3` line remains on `latest`.
|
|
20
20
|
|
|
21
21
|
## Why use this package?
|
|
@@ -40,13 +40,13 @@ output.
|
|
|
40
40
|
Use the Nuxt CLI:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
npx nuxi module add @lupinum/ginko-content@1.0.0-beta.
|
|
43
|
+
npx nuxi module add @lupinum/ginko-content@1.0.0-beta.2
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Or install and register the module by hand:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
pnpm add @lupinum/ginko-content@1.0.0-beta.
|
|
49
|
+
pnpm add @lupinum/ginko-content@1.0.0-beta.2
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
```ts
|
|
@@ -21,6 +21,12 @@ const renderChildren = (node, ctx) => (node.children || []).map((child) => rende
|
|
|
21
21
|
const block = (value) => value.trim() ? `${value.trim()}
|
|
22
22
|
|
|
23
23
|
` : "";
|
|
24
|
+
const codeFenceInfo = (node) => {
|
|
25
|
+
const language = typeof node.props?.language === "string" ? node.props.language.replace(/[\r\n]/g, " ").trim() : "";
|
|
26
|
+
const filename = typeof node.props?.filename === "string" ? node.props.filename.replace(/[\r\n]/g, " ").trim() : "";
|
|
27
|
+
const escapedFilename = filename.replace(/\\/g, "\\\\").replace(/\]/g, "\\]");
|
|
28
|
+
return `${language}${escapedFilename ? ` [${escapedFilename}]` : ""}`;
|
|
29
|
+
};
|
|
24
30
|
const renderList = (node, ctx, ordered = false) => block((node.children || []).map((child, index) => {
|
|
25
31
|
const [first, ...rest] = child.children || [];
|
|
26
32
|
let task = "";
|
|
@@ -136,7 +142,7 @@ const renderNode = (node, ctx) => {
|
|
|
136
142
|
case "code":
|
|
137
143
|
return `\`${node.value || textValue(node)}\``;
|
|
138
144
|
case "pre":
|
|
139
|
-
return block(
|
|
145
|
+
return block(`\`\`\`${codeFenceInfo(node)}
|
|
140
146
|
${textValue(node)}
|
|
141
147
|
\`\`\``);
|
|
142
148
|
case "a": {
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -33,7 +33,7 @@ import { assertCanonicalHighlightOptionNames } from '../dist/parsers/markdown-pl
|
|
|
33
33
|
import { BUILTIN_MARKDOWN_RENDER_CONTRACTS } from '../dist/core/markdown/builtin-render-contracts.js';
|
|
34
34
|
|
|
35
35
|
const name = "@lupinum/ginko-content";
|
|
36
|
-
const version = "1.0.0-beta.
|
|
36
|
+
const version = "1.0.0-beta.2";
|
|
37
37
|
const peerDependencies = {
|
|
38
38
|
nuxt: ">=4.5.1 <5"};
|
|
39
39
|
|
|
@@ -26,7 +26,7 @@ const configuredLocales = () => {
|
|
|
26
26
|
};
|
|
27
27
|
const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
28
28
|
const requireAgentSourceDocument = (value) => {
|
|
29
|
-
if (!isRecord(value) || typeof value.id !== "string" || typeof value.locale !== "string" || !isRecord(value.route) || typeof value.route.resolvedPath !== "string" || !isRecord(value.resolution) || !isRecord(value.resolution.resolved) || typeof value.resolution.resolved.locale !== "string" || value.title !== void 0 && typeof value.title !== "string" || value.description !== void 0 && typeof value.description !== "string" || value.updated !== void 0 && typeof value.updated !== "string" || value.draft !== void 0 && typeof value.draft !== "boolean" || value.partial !== void 0 && typeof value.partial !== "boolean" || value.navigationFile !== void 0 && typeof value.navigationFile !== "boolean") {
|
|
29
|
+
if (!isRecord(value) || typeof value.id !== "string" || typeof value.locale !== "string" || !isRecord(value.route) || typeof value.route.resolvedPath !== "string" || !isRecord(value.resolution) || !isRecord(value.resolution.resolved) || typeof value.resolution.resolved.locale !== "string" || value.title !== void 0 && typeof value.title !== "string" || value.description !== void 0 && typeof value.description !== "string" || value.updated !== void 0 && typeof value.updated !== "string" || value.draft !== void 0 && typeof value.draft !== "boolean" || value.partial !== void 0 && typeof value.partial !== "boolean" || value.navigationFile !== void 0 && typeof value.navigationFile !== "boolean" || value.order !== void 0 && typeof value.order !== "number") {
|
|
30
30
|
throw new Error(
|
|
31
31
|
"Agent markdown requires the canonical localized document envelope (`route.resolvedPath` and `resolution.resolved.locale`)."
|
|
32
32
|
);
|
|
@@ -87,6 +87,7 @@ const toAgentMarkdown = (collection, page, options) => {
|
|
|
87
87
|
description,
|
|
88
88
|
markdown: renderAgentMarkdown(page, collection, path, locale, options),
|
|
89
89
|
...page.file?.path ? { sourceFile: page.file?.path } : {},
|
|
90
|
+
...page.order !== void 0 ? { order: page.order } : {},
|
|
90
91
|
canonicalUrl: path,
|
|
91
92
|
...page.updated ? { lastModified: page.updated } : {},
|
|
92
93
|
metadataFields: options.metadata,
|
|
@@ -133,6 +134,7 @@ export async function queryMarkdownEnabledContent(event, options = {}) {
|
|
|
133
134
|
"description",
|
|
134
135
|
"updated",
|
|
135
136
|
"navigation",
|
|
137
|
+
"order",
|
|
136
138
|
"robots",
|
|
137
139
|
"sitemap"
|
|
138
140
|
],
|
|
@@ -155,6 +157,7 @@ export async function queryMarkdownEnabledContent(event, options = {}) {
|
|
|
155
157
|
title,
|
|
156
158
|
description,
|
|
157
159
|
...row.file?.path ? { sourceFile: row.file?.path } : {},
|
|
160
|
+
...row.order !== void 0 ? { order: row.order } : {},
|
|
158
161
|
canonicalUrl: path,
|
|
159
162
|
...row.updated ? { lastModified: row.updated } : {},
|
|
160
163
|
metadataFields: agentOptions.metadata,
|
|
@@ -88,6 +88,8 @@ const createGinkoAgentPage = (meta, locale, siteUrl) => {
|
|
|
88
88
|
locale: meta.locale || locale,
|
|
89
89
|
source: "ginko",
|
|
90
90
|
collection: meta.collection,
|
|
91
|
+
sourceFile: meta.sourceFile,
|
|
92
|
+
order: meta.order,
|
|
91
93
|
updated: meta.lastModified,
|
|
92
94
|
metadataFields: meta.metadataFields,
|
|
93
95
|
includeInIndex: meta.includeInIndex,
|
|
@@ -125,9 +127,18 @@ const createAppOwnedAgentPages = async (locale, siteUrl) => {
|
|
|
125
127
|
}
|
|
126
128
|
return result;
|
|
127
129
|
};
|
|
130
|
+
const sourcePathCollator = new Intl.Collator("en", { numeric: true, sensitivity: "base" });
|
|
128
131
|
const sortPages = (pages) => pages.sort((a, b) => {
|
|
129
132
|
const sectionDelta = a.sectionOrder - b.sectionOrder;
|
|
130
133
|
if (sectionDelta) return sectionDelta;
|
|
134
|
+
if (a.sourceFile && b.sourceFile) {
|
|
135
|
+
const sourceDelta = sourcePathCollator.compare(a.sourceFile, b.sourceFile);
|
|
136
|
+
if (sourceDelta) return sourceDelta;
|
|
137
|
+
}
|
|
138
|
+
if (a.order !== void 0 && b.order !== void 0) {
|
|
139
|
+
const orderDelta = a.order - b.order;
|
|
140
|
+
if (orderDelta) return orderDelta;
|
|
141
|
+
}
|
|
131
142
|
return a.path.localeCompare(b.path);
|
|
132
143
|
});
|
|
133
144
|
const assertUniqueAgentPages = (pages) => {
|
package/dist/web-types.json
CHANGED