@farming-labs/next 0.2.72 → 0.2.74
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChangelogDirectory, ChangelogTOC } from "./changelog-rail-search.mjs";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { resolveChangelogConfig } from "@farming-labs/docs";
|
|
4
|
+
import { collectDocsMarkdownSections, resolveChangelogConfig } from "@farming-labs/docs";
|
|
5
5
|
import Link from "next/link";
|
|
6
6
|
import { notFound } from "next/navigation";
|
|
7
7
|
import { createElement, isValidElement } from "react";
|
|
@@ -40,58 +40,13 @@ function truncatePaginationTitle(value, maxLength = 72) {
|
|
|
40
40
|
function truncatePaginationDescription(value, maxLength = 110) {
|
|
41
41
|
return truncatePaginationText(value, maxLength);
|
|
42
42
|
}
|
|
43
|
-
function stripInlineMarkdown(value) {
|
|
44
|
-
return normalizeWhitespace(value.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, "$1").replace(/\[([^\]]+)\]\(([^)]+)\)/g, "$1").replace(/`([^`]+)`/g, "$1").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/__([^_]+)__/g, "$1").replace(/_([^_]+)_/g, "$1").replace(/<[^>]+>/g, ""));
|
|
45
|
-
}
|
|
46
|
-
function slugifyHeading(text) {
|
|
47
|
-
return text.trim().toLowerCase().replace(/[`'"‘’“”]/g, "").replace(/&/g, " and ").replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
48
|
-
}
|
|
49
|
-
function extractHeadingId(value) {
|
|
50
|
-
const match = value.match(/\s+(?:\[#([A-Za-z0-9._:-]+)\]|\{#([A-Za-z0-9._:-]+)\})\s*$/);
|
|
51
|
-
if (!match) return { title: value };
|
|
52
|
-
return {
|
|
53
|
-
title: value.slice(0, match.index).trimEnd(),
|
|
54
|
-
id: match[1] ?? match[2]
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
43
|
function extractChangelogToc(sourcePath) {
|
|
58
44
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
let inFence = false;
|
|
65
|
-
for (const line of lines) {
|
|
66
|
-
const trimmed = line.trim();
|
|
67
|
-
if (!frontmatterDone && trimmed === "---") {
|
|
68
|
-
inFrontmatter = !inFrontmatter;
|
|
69
|
-
if (!inFrontmatter) frontmatterDone = true;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (inFrontmatter) continue;
|
|
73
|
-
if (/^(```|~~~)/.test(trimmed)) {
|
|
74
|
-
inFence = !inFence;
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (inFence) continue;
|
|
78
|
-
const headingMatch = line.match(/^(#{2,4})\s+(.+?)\s*#*\s*$/);
|
|
79
|
-
if (!headingMatch) continue;
|
|
80
|
-
const depth = headingMatch[1].length;
|
|
81
|
-
const resolvedHeading = extractHeadingId(headingMatch[2]);
|
|
82
|
-
const title = stripInlineMarkdown(resolvedHeading.title);
|
|
83
|
-
if (!title) continue;
|
|
84
|
-
const baseSlug = resolvedHeading.id || slugifyHeading(title) || `section-${items.length + 1}`;
|
|
85
|
-
const seen = seenSlugs.get(baseSlug) ?? 0;
|
|
86
|
-
seenSlugs.set(baseSlug, seen + 1);
|
|
87
|
-
const slug = resolvedHeading.id ? baseSlug : seen === 0 ? baseSlug : `${baseSlug}-${seen}`;
|
|
88
|
-
items.push({
|
|
89
|
-
title,
|
|
90
|
-
url: `#${slug}`,
|
|
91
|
-
depth
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
return items;
|
|
45
|
+
return collectDocsMarkdownSections(readFileSync(join(process.cwd(), sourcePath), "utf-8")).filter((heading) => heading.level >= 2 && heading.level <= 4 && heading.heading).map((heading) => ({
|
|
46
|
+
title: heading.heading,
|
|
47
|
+
url: `#${encodeURIComponent(heading.id)}`,
|
|
48
|
+
depth: heading.level
|
|
49
|
+
}));
|
|
95
50
|
} catch {
|
|
96
51
|
return [];
|
|
97
52
|
}
|
package/dist/layout.mjs
CHANGED
|
@@ -46,7 +46,9 @@ function withAnalyticsAction(route) {
|
|
|
46
46
|
if (!url.searchParams.has("action")) url.searchParams.set("action", "analytics");
|
|
47
47
|
return route.startsWith("http://") || route.startsWith("https://") ? url.toString() : `${url.pathname}${url.search}${url.hash}`;
|
|
48
48
|
} catch {
|
|
49
|
-
const
|
|
49
|
+
const hashIndex = route.indexOf("#");
|
|
50
|
+
const pathAndQuery = hashIndex >= 0 ? route.slice(0, hashIndex) : route;
|
|
51
|
+
const hash = hashIndex >= 0 ? route.slice(hashIndex + 1) : "";
|
|
50
52
|
return `${pathAndQuery}${pathAndQuery.includes("?") ? "&" : "?"}action=analytics${hash ? `#${hash}` : ""}`;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import { remarkHeading as
|
|
2
|
-
|
|
1
|
+
import { remarkHeading as remarkHeading$1 } from "fumadocs-core/mdx-plugins/remark-heading";
|
|
2
|
+
|
|
3
|
+
//#region src/mdx-plugins/remark-heading.d.ts
|
|
4
|
+
declare function remarkHeading(options?: Parameters<typeof remarkHeading$1>[0]): ReturnType<typeof remarkHeading$1>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { remarkHeading as default };
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyDocsMarkdownHeadingAnchors, encodeDocsHeadingTocUrls, isolateDocsMarkdownPromptReferences, withDocsMarkdownRenderableHeadings } from "@farming-labs/docs";
|
|
2
|
+
import { remarkHeading as remarkHeading$1 } from "fumadocs-core/mdx-plugins/remark-heading";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
//#region src/mdx-plugins/remark-heading.ts
|
|
5
|
+
function remarkHeading(options = {}) {
|
|
6
|
+
if (options.slug) {
|
|
7
|
+
const customRemarkHeading = remarkHeading$1(options);
|
|
8
|
+
return (root, file) => {
|
|
9
|
+
isolateDocsMarkdownPromptReferences(root, file.value);
|
|
10
|
+
const result = withDocsMarkdownRenderableHeadings(root, () => customRemarkHeading(root, file, () => void 0));
|
|
11
|
+
encodeDocsHeadingTocUrls(file.data.toc);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return (root, file) => {
|
|
16
|
+
isolateDocsMarkdownPromptReferences(root, file.value);
|
|
17
|
+
applyDocsMarkdownHeadingAnchors(root, { customId: options.customId });
|
|
18
|
+
withDocsMarkdownRenderableHeadings(root, () => remarkHeading$1({
|
|
19
|
+
...options,
|
|
20
|
+
customId: false
|
|
21
|
+
})(root, file, () => void 0));
|
|
22
|
+
encodeDocsHeadingTocUrls(file.data.toc);
|
|
23
|
+
return root;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { remarkHeading as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/next",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.74",
|
|
4
4
|
"description": "Next.js adapter for @farming-labs/docs — MDX config wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -102,17 +102,18 @@
|
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@babel/types": "7.29.7",
|
|
105
|
+
"@mdx-js/mdx": "^3.1.1",
|
|
105
106
|
"@types/node": "^22.10.0",
|
|
106
107
|
"@types/react": "^19.2.2",
|
|
107
108
|
"@types/react-dom": "^19.2.2",
|
|
108
109
|
"tsdown": "^0.20.3",
|
|
109
110
|
"typescript": "^5.9.3",
|
|
110
111
|
"vitest": "^4.1.8",
|
|
111
|
-
"@farming-labs/docs": "0.2.
|
|
112
|
-
"@farming-labs/theme": "0.2.
|
|
112
|
+
"@farming-labs/docs": "0.2.74",
|
|
113
|
+
"@farming-labs/theme": "0.2.74"
|
|
113
114
|
},
|
|
114
115
|
"peerDependencies": {
|
|
115
|
-
"@farming-labs/docs": ">=0.2.
|
|
116
|
+
"@farming-labs/docs": ">=0.2.73",
|
|
116
117
|
"@farming-labs/theme": ">=0.0.1",
|
|
117
118
|
"next": ">=16.0.0",
|
|
118
119
|
"react": ">=19.2.0",
|