@farming-labs/theme 0.0.59 → 0.0.60
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/docs-api.mjs +2 -2
- package/dist/docs-layout.mjs +31 -4
- package/package.json +2 -2
package/dist/docs-api.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getNextAppDir } from "./get-app-dir.mjs";
|
|
2
1
|
import { withLangInUrl } from "./i18n.mjs";
|
|
2
|
+
import { getNextAppDir } from "./get-app-dir.mjs";
|
|
3
|
+
import { resolveDocsI18n, resolveDocsLocale } from "@farming-labs/docs";
|
|
3
4
|
import fs from "node:fs";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import matter from "gray-matter";
|
|
6
|
-
import { resolveDocsI18n, resolveDocsLocale } from "@farming-labs/docs";
|
|
7
7
|
import { createSearchAPI } from "fumadocs-core/search/server";
|
|
8
8
|
|
|
9
9
|
//#region src/docs-api.ts
|
package/dist/docs-layout.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getNextAppDir } from "./get-app-dir.mjs";
|
|
2
1
|
import { serializeIcon } from "./serialize-icon.mjs";
|
|
3
2
|
import { withLangInUrl } from "./i18n.mjs";
|
|
4
3
|
import { DocsPageClient } from "./docs-page-client.mjs";
|
|
@@ -7,14 +6,31 @@ import { DocsCommandSearch } from "./docs-command-search.mjs";
|
|
|
7
6
|
import { SidebarSearchWithAI } from "./sidebar-search-ai.mjs";
|
|
8
7
|
import { LocaleThemeControl } from "./locale-theme-control.mjs";
|
|
9
8
|
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
10
|
-
import fs from "node:fs";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
import matter from "gray-matter";
|
|
13
9
|
import { Suspense } from "react";
|
|
14
10
|
import { buildPageOpenGraph, buildPageTwitter } from "@farming-labs/docs";
|
|
15
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
12
|
|
|
17
13
|
//#region src/docs-layout.tsx
|
|
14
|
+
function runtimeRequire(id) {
|
|
15
|
+
const requireFn = eval("require");
|
|
16
|
+
return requireFn(id);
|
|
17
|
+
}
|
|
18
|
+
function getNodeFs() {
|
|
19
|
+
return runtimeRequire("node:fs");
|
|
20
|
+
}
|
|
21
|
+
function getNodePath() {
|
|
22
|
+
return runtimeRequire("node:path");
|
|
23
|
+
}
|
|
24
|
+
function getMatter() {
|
|
25
|
+
const module = runtimeRequire("gray-matter");
|
|
26
|
+
return module.default ?? module;
|
|
27
|
+
}
|
|
28
|
+
function getNextAppDir(root) {
|
|
29
|
+
const fs = getNodeFs();
|
|
30
|
+
const path = getNodePath();
|
|
31
|
+
if (fs.existsSync(path.join(root, "src", "app"))) return "src/app";
|
|
32
|
+
return "app";
|
|
33
|
+
}
|
|
18
34
|
/** Resolve a frontmatter `icon` string to a ReactNode via the icon registry. */
|
|
19
35
|
function resolveIcon(iconKey, registry) {
|
|
20
36
|
if (!iconKey || !registry) return void 0;
|
|
@@ -22,6 +38,8 @@ function resolveIcon(iconKey, registry) {
|
|
|
22
38
|
}
|
|
23
39
|
/** Read frontmatter from a page.mdx file. */
|
|
24
40
|
function readFrontmatter(filePath) {
|
|
41
|
+
const fs = getNodeFs();
|
|
42
|
+
const matter = getMatter();
|
|
25
43
|
try {
|
|
26
44
|
const { data } = matter(fs.readFileSync(filePath, "utf-8"));
|
|
27
45
|
return data;
|
|
@@ -31,6 +49,8 @@ function readFrontmatter(filePath) {
|
|
|
31
49
|
}
|
|
32
50
|
/** Check if a directory has any subdirectories that contain page.mdx. */
|
|
33
51
|
function hasChildPages(dir) {
|
|
52
|
+
const fs = getNodeFs();
|
|
53
|
+
const path = getNodePath();
|
|
34
54
|
if (!fs.existsSync(dir)) return false;
|
|
35
55
|
for (const name of fs.readdirSync(dir)) {
|
|
36
56
|
const full = path.join(dir, name);
|
|
@@ -54,6 +74,7 @@ function resolveDocsLocaleContext(config, locale) {
|
|
|
54
74
|
const entryBase = config.entry ?? "docs";
|
|
55
75
|
const i18n = resolveDocsI18nConfig(getDocsI18n(config));
|
|
56
76
|
const contentDir = config.contentDir;
|
|
77
|
+
const path = getNodePath();
|
|
57
78
|
function resolveContentDir(localeValue) {
|
|
58
79
|
if (!contentDir) {
|
|
59
80
|
const appDir = getNextAppDir(process.cwd());
|
|
@@ -78,6 +99,8 @@ function buildTree(config, ctx, flat = false) {
|
|
|
78
99
|
const icons = config.icons;
|
|
79
100
|
const ordering = config.ordering;
|
|
80
101
|
const rootChildren = [];
|
|
102
|
+
const fs = getNodeFs();
|
|
103
|
+
const path = getNodePath();
|
|
81
104
|
if (fs.existsSync(path.join(docsDir, "page.mdx"))) {
|
|
82
105
|
const data = readFrontmatter(path.join(docsDir, "page.mdx"));
|
|
83
106
|
rootChildren.push({
|
|
@@ -204,6 +227,8 @@ function localizeTreeUrls(tree, locale) {
|
|
|
204
227
|
function buildLastModifiedMap(ctx) {
|
|
205
228
|
const docsDir = ctx.docsDir;
|
|
206
229
|
const map = {};
|
|
230
|
+
const fs = getNodeFs();
|
|
231
|
+
const path = getNodePath();
|
|
207
232
|
function formatDate(date) {
|
|
208
233
|
return date.toLocaleDateString("en-US", {
|
|
209
234
|
year: "numeric",
|
|
@@ -233,6 +258,8 @@ function buildLastModifiedMap(ctx) {
|
|
|
233
258
|
function buildDescriptionMap(ctx) {
|
|
234
259
|
const docsDir = ctx.docsDir;
|
|
235
260
|
const map = {};
|
|
261
|
+
const fs = getNodeFs();
|
|
262
|
+
const path = getNodePath();
|
|
236
263
|
function scan(dir, slugParts) {
|
|
237
264
|
if (!fs.existsSync(dir)) return;
|
|
238
265
|
const pagePath = path.join(dir, "page.mdx");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.60",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"tsdown": "^0.20.3",
|
|
116
116
|
"typescript": "^5.9.3",
|
|
117
117
|
"vitest": "^3.2.4",
|
|
118
|
-
"@farming-labs/docs": "0.0.
|
|
118
|
+
"@farming-labs/docs": "0.0.60"
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
121
|
"@farming-labs/docs": ">=0.0.1",
|