@farming-labs/next 0.1.77 → 0.1.78
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/dist/changelog.mjs
CHANGED
|
@@ -438,7 +438,7 @@ function createNextChangelogIndexMetadata(config) {
|
|
|
438
438
|
return createPageMetadata(config, {
|
|
439
439
|
title: changelog.title,
|
|
440
440
|
description: changelog.description
|
|
441
|
-
});
|
|
441
|
+
}, void 0, getListingUrl(config));
|
|
442
442
|
}
|
|
443
443
|
function createNextChangelogEntryMetadata(config, entries) {
|
|
444
444
|
return async function generateMetadata(props) {
|
|
@@ -449,12 +449,12 @@ function createNextChangelogEntryMetadata(config, entries) {
|
|
|
449
449
|
return createPageMetadata(config, {
|
|
450
450
|
title: changelog.title,
|
|
451
451
|
description: changelog.description
|
|
452
|
-
});
|
|
452
|
+
}, void 0, getListingUrl(config));
|
|
453
453
|
}
|
|
454
454
|
return createPageMetadata(config, {
|
|
455
455
|
title: entry.title,
|
|
456
456
|
description: entry.description
|
|
457
|
-
});
|
|
457
|
+
}, void 0, `${getListingUrl(config)}/${entry.slug}`);
|
|
458
458
|
};
|
|
459
459
|
}
|
|
460
460
|
|
package/dist/config.mjs
CHANGED
|
@@ -231,6 +231,7 @@ function createDocsWorkspaceAliases() {
|
|
|
231
231
|
"@farming-labs/next/mdx-plugins/rehype-toc": "./packages/next/src/mdx-plugins/rehype-toc.ts",
|
|
232
232
|
"@farming-labs/next/mdx-plugins/remark-heading": "./packages/next/src/mdx-plugins/remark-heading.ts",
|
|
233
233
|
"@farming-labs/next/mdx-plugins/remark-og": "./packages/next/src/mdx-plugins/remark-og.ts",
|
|
234
|
+
"@farming-labs/next/mdx-plugins/remark-markdown-alternate": "./packages/next/src/mdx-plugins/remark-markdown-alternate.ts",
|
|
234
235
|
"@farming-labs/theme": "./packages/fumadocs/src/index.ts",
|
|
235
236
|
"@farming-labs/theme/api": "./packages/fumadocs/src/docs-api.ts",
|
|
236
237
|
"@farming-labs/theme/client-hooks": "./packages/fumadocs/src/docs-client-hooks.tsx",
|
|
@@ -1149,6 +1150,12 @@ function withDocs(nextConfig = {}) {
|
|
|
1149
1150
|
const ogEndpoint = readOgEndpoint(root);
|
|
1150
1151
|
const remarkPlugins = ["remark-gfm", "remark-frontmatter"];
|
|
1151
1152
|
if (ogEndpoint) remarkPlugins.push(["@farming-labs/next/mdx-plugins/remark-og", { endpoint: ogEndpoint }]);
|
|
1153
|
+
remarkPlugins.push(["@farming-labs/next/mdx-plugins/remark-markdown-alternate", {
|
|
1154
|
+
entry,
|
|
1155
|
+
appDir,
|
|
1156
|
+
contentDir: docsContentDir,
|
|
1157
|
+
enabled: !isStaticExport
|
|
1158
|
+
}]);
|
|
1152
1159
|
remarkPlugins.push(["remark-mdx-frontmatter", { name: "metadata" }], "@farming-labs/next/mdx-plugins/remark-heading");
|
|
1153
1160
|
const withMDX = createMDX({
|
|
1154
1161
|
extension: /\.mdx?$/,
|
|
@@ -1206,6 +1213,7 @@ function withDocs(nextConfig = {}) {
|
|
|
1206
1213
|
"@farming-labs/next/changelog": join(workspaceRoot, "packages", "next", "dist", "changelog.mjs"),
|
|
1207
1214
|
"@farming-labs/next/client-callbacks": join(workspaceRoot, "packages", "next", "dist", "client-callbacks.mjs"),
|
|
1208
1215
|
"@farming-labs/next/layout": join(workspaceRoot, "packages", "next", "dist", "layout.mjs"),
|
|
1216
|
+
"@farming-labs/next/mdx-plugins/remark-markdown-alternate": join(workspaceRoot, "packages", "next", "dist", "mdx-plugins", "remark-markdown-alternate.mjs"),
|
|
1209
1217
|
"@farming-labs/theme$": join(workspaceRoot, "packages", "fumadocs", "dist", "index.mjs"),
|
|
1210
1218
|
"@farming-labs/theme/api": join(workspaceRoot, "packages", "fumadocs", "dist", "docs-api.mjs")
|
|
1211
1219
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/mdx-plugins/remark-markdown-alternate.d.ts
|
|
2
|
+
interface RemarkMarkdownAlternateOptions {
|
|
3
|
+
entry?: string;
|
|
4
|
+
appDir?: string;
|
|
5
|
+
contentDir?: string;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface MarkdownNode {
|
|
9
|
+
type: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
}
|
|
12
|
+
interface VFileLike {
|
|
13
|
+
path?: string;
|
|
14
|
+
history?: string[];
|
|
15
|
+
}
|
|
16
|
+
declare function remarkMarkdownAlternate(options?: RemarkMarkdownAlternateOptions): (tree: {
|
|
17
|
+
children: MarkdownNode[];
|
|
18
|
+
}, file?: VFileLike) => void;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { remarkMarkdownAlternate as default };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { toDocsMarkdownUrl } from "@farming-labs/docs";
|
|
2
|
+
|
|
3
|
+
//#region src/mdx-plugins/remark-markdown-alternate.ts
|
|
4
|
+
function normalizePath(value) {
|
|
5
|
+
return value.replace(/\\/g, "/").replace(/\/+/g, "/");
|
|
6
|
+
}
|
|
7
|
+
function normalizeSegment(value, fallback) {
|
|
8
|
+
return (value ?? fallback).replace(/^\/+|\/+$/g, "") || fallback;
|
|
9
|
+
}
|
|
10
|
+
function escapeYamlString(value) {
|
|
11
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
12
|
+
}
|
|
13
|
+
function routeFromSourcePath(filePath, options) {
|
|
14
|
+
const normalized = `/${normalizePath(filePath).replace(/^\/+/, "")}`;
|
|
15
|
+
if (!/\/page\.mdx?$/.test(normalized)) return null;
|
|
16
|
+
const entry = normalizeSegment(options.entry, "docs");
|
|
17
|
+
const candidates = [
|
|
18
|
+
options.contentDir,
|
|
19
|
+
options.appDir ? `${options.appDir}/${entry}` : void 0,
|
|
20
|
+
`src/app/${entry}`,
|
|
21
|
+
`app/${entry}`
|
|
22
|
+
].filter((candidate) => typeof candidate === "string" && candidate.length > 0).map((candidate) => normalizePath(candidate).replace(/^\/+|\/+$/g, ""));
|
|
23
|
+
for (const candidate of candidates) {
|
|
24
|
+
const marker = `/${candidate}/`;
|
|
25
|
+
const markerIndex = normalized.lastIndexOf(marker);
|
|
26
|
+
if (markerIndex === -1) continue;
|
|
27
|
+
const relativePath = normalized.slice(markerIndex + marker.length);
|
|
28
|
+
if (!relativePath.endsWith("page.mdx") && !relativePath.endsWith("page.md")) continue;
|
|
29
|
+
const slug = relativePath.replace(/\/?page\.mdx?$/, "").replace(/^\/+|\/+$/g, "");
|
|
30
|
+
return slug ? `/${entry}/${slug}` : `/${entry}`;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function getFilePath(file) {
|
|
35
|
+
return file?.path ?? file?.history?.[0];
|
|
36
|
+
}
|
|
37
|
+
function hasAlternates(yaml) {
|
|
38
|
+
return /^\s*alternates\s*:/m.test(yaml);
|
|
39
|
+
}
|
|
40
|
+
function alternateYaml(url) {
|
|
41
|
+
return [
|
|
42
|
+
"alternates:",
|
|
43
|
+
" types:",
|
|
44
|
+
` text/markdown: "${escapeYamlString(toDocsMarkdownUrl(url))}"`
|
|
45
|
+
].join("\n");
|
|
46
|
+
}
|
|
47
|
+
function remarkMarkdownAlternate(options = {}) {
|
|
48
|
+
return (tree, file) => {
|
|
49
|
+
if (options.enabled === false) return;
|
|
50
|
+
const filePath = getFilePath(file);
|
|
51
|
+
if (!filePath) return;
|
|
52
|
+
const route = routeFromSourcePath(filePath, options);
|
|
53
|
+
if (!route) return;
|
|
54
|
+
const yamlNode = tree.children.find((node) => node.type === "yaml");
|
|
55
|
+
if (yamlNode?.value) {
|
|
56
|
+
if (hasAlternates(yamlNode.value)) return;
|
|
57
|
+
yamlNode.value += `\n${alternateYaml(route)}`;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
tree.children.unshift({
|
|
61
|
+
type: "yaml",
|
|
62
|
+
value: alternateYaml(route)
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
export { remarkMarkdownAlternate as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.78",
|
|
4
4
|
"description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -73,6 +73,11 @@
|
|
|
73
73
|
"types": "./dist/mdx-plugins/remark-og.d.mts",
|
|
74
74
|
"import": "./dist/mdx-plugins/remark-og.mjs",
|
|
75
75
|
"default": "./dist/mdx-plugins/remark-og.mjs"
|
|
76
|
+
},
|
|
77
|
+
"./mdx-plugins/remark-markdown-alternate": {
|
|
78
|
+
"types": "./dist/mdx-plugins/remark-markdown-alternate.d.mts",
|
|
79
|
+
"import": "./dist/mdx-plugins/remark-markdown-alternate.mjs",
|
|
80
|
+
"default": "./dist/mdx-plugins/remark-markdown-alternate.mjs"
|
|
76
81
|
}
|
|
77
82
|
},
|
|
78
83
|
"dependencies": {
|
|
@@ -95,8 +100,8 @@
|
|
|
95
100
|
"tsdown": "^0.20.3",
|
|
96
101
|
"typescript": "^5.9.3",
|
|
97
102
|
"vitest": "^3.2.4",
|
|
98
|
-
"@farming-labs/docs": "0.1.
|
|
99
|
-
"@farming-labs/theme": "0.1.
|
|
103
|
+
"@farming-labs/docs": "0.1.78",
|
|
104
|
+
"@farming-labs/theme": "0.1.78"
|
|
100
105
|
},
|
|
101
106
|
"peerDependencies": {
|
|
102
107
|
"@farming-labs/docs": ">=0.0.1",
|