czon 0.7.6 → 0.7.7
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/paths.js +3 -1
- package/dist/process/template.js +23 -5
- package/dist/ssg/ContentPage.js +2 -0
- package/dist/ssg/IndexPage.js +2 -0
- package/dist/ssg/RootPage.js +2 -0
- package/dist/ssg/resourceMap.js +9 -1
- package/package.json +1 -1
package/dist/paths.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LOCAL_OPENCODE_AGENT_DIR = exports.GLOBAL_OPENCODE_AGENT_DIR = exports.CZON_META_PATH = exports.CZON_SRC_DIR = exports.CZON_DIST_RAW_CONTENT_DIR = exports.CZON_DIST_DIR = exports.CZON_DIR = exports.INPUT_DIR = void 0;
|
|
3
|
+
exports.LOCAL_OPENCODE_AGENT_DIR = exports.GLOBAL_OPENCODE_AGENT_DIR = exports.CZON_DIST_CUSTOM_STYLE_PATH = exports.CZON_CUSTOM_STYLE_PATH = exports.CZON_META_PATH = exports.CZON_SRC_DIR = exports.CZON_DIST_RAW_CONTENT_DIR = exports.CZON_DIST_DIR = exports.CZON_DIR = exports.INPUT_DIR = void 0;
|
|
4
4
|
const os_1 = require("os");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
exports.INPUT_DIR = process.cwd();
|
|
@@ -9,6 +9,8 @@ exports.CZON_DIST_DIR = (0, path_1.join)(exports.CZON_DIR, 'dist');
|
|
|
9
9
|
exports.CZON_DIST_RAW_CONTENT_DIR = (0, path_1.join)(exports.CZON_DIST_DIR, '__raw__');
|
|
10
10
|
exports.CZON_SRC_DIR = (0, path_1.join)(exports.CZON_DIR, 'src');
|
|
11
11
|
exports.CZON_META_PATH = (0, path_1.join)(exports.CZON_DIR, 'meta.json');
|
|
12
|
+
exports.CZON_CUSTOM_STYLE_PATH = (0, path_1.join)(exports.CZON_DIR, 'style.css');
|
|
13
|
+
exports.CZON_DIST_CUSTOM_STYLE_PATH = (0, path_1.join)(exports.CZON_DIST_DIR, 'style.css');
|
|
12
14
|
/**
|
|
13
15
|
* ~/.config/opencode/agents/
|
|
14
16
|
*/
|
package/dist/process/template.js
CHANGED
|
@@ -65,13 +65,24 @@ const copyFavicon = async () => {
|
|
|
65
65
|
await fs.copyFile(defaultFaviconSource, faviconTarget);
|
|
66
66
|
console.info(`📄 Copied default favicon to: ${faviconTarget}`);
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* 检测并复制自定义样式文件
|
|
70
|
+
* @returns 是否存在自定义样式
|
|
71
|
+
*/
|
|
72
|
+
const copyCustomStyle = async () => {
|
|
73
|
+
if (await (0, isExists_1.isExists)(paths_1.CZON_CUSTOM_STYLE_PATH)) {
|
|
74
|
+
await fs.mkdir(path.dirname(paths_1.CZON_DIST_CUSTOM_STYLE_PATH), { recursive: true });
|
|
75
|
+
await fs.copyFile(paths_1.CZON_CUSTOM_STYLE_PATH, paths_1.CZON_DIST_CUSTOM_STYLE_PATH);
|
|
76
|
+
console.info(`🎨 Copied custom style from ${paths_1.CZON_CUSTOM_STYLE_PATH} to: ${paths_1.CZON_DIST_CUSTOM_STYLE_PATH}`);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
};
|
|
68
81
|
/**
|
|
69
82
|
* 使用简单的爬虫抓取生成的站点页面
|
|
70
83
|
*/
|
|
71
84
|
const spiderStaticSiteGenerator = async () => {
|
|
72
85
|
(0, sitemap_1.clearSitemapCollection)();
|
|
73
|
-
// 复制 favicon 图标
|
|
74
|
-
await copyFavicon();
|
|
75
86
|
const queue = ['/index.html', '/404.html'];
|
|
76
87
|
// 将每个语言的首页加入队列
|
|
77
88
|
for (const lang of metadata_1.MetaData.options.langs || []) {
|
|
@@ -79,6 +90,12 @@ const spiderStaticSiteGenerator = async () => {
|
|
|
79
90
|
}
|
|
80
91
|
const isVisited = new Set();
|
|
81
92
|
const contents = [];
|
|
93
|
+
// 检测并复制自定义样式
|
|
94
|
+
const hasCustomStyle = await copyCustomStyle();
|
|
95
|
+
isVisited.add('/style.css'); // 标记自定义样式为已访问
|
|
96
|
+
// 复制 favicon 图标
|
|
97
|
+
await copyFavicon();
|
|
98
|
+
isVisited.add('/favicon.ico'); // 标记 favicon 为已访问
|
|
82
99
|
// 预加载所有 Markdown 内容,因为 React 内部异步渲染比较麻烦
|
|
83
100
|
for (const file of metadata_1.MetaData.files) {
|
|
84
101
|
if (!file.path.endsWith('.md'))
|
|
@@ -107,6 +124,7 @@ const spiderStaticSiteGenerator = async () => {
|
|
|
107
124
|
path: currentPath,
|
|
108
125
|
site: metadata_1.MetaData,
|
|
109
126
|
contents,
|
|
127
|
+
hasCustomStyle,
|
|
110
128
|
});
|
|
111
129
|
console.info(`🕷️ Crawled ${currentPath}`);
|
|
112
130
|
// 收集 URL 用于 sitemap
|
|
@@ -137,9 +155,9 @@ const spiderStaticSiteGenerator = async () => {
|
|
|
137
155
|
const resolvedPath = path.resolve('/', path.dirname(currentPath), link);
|
|
138
156
|
if (resolvedPath.startsWith('/__raw__/'))
|
|
139
157
|
continue; // 跳过原始内容目录
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
// console.info(
|
|
159
|
+
// ` ➕ Found link: ${link} -> ${resolvedPath} (${isVisited.has(resolvedPath) ? 'visited' : 'new'})`
|
|
160
|
+
// );
|
|
143
161
|
if (!isVisited.has(resolvedPath)) {
|
|
144
162
|
queue.push(resolvedPath);
|
|
145
163
|
}
|
package/dist/ssg/ContentPage.js
CHANGED
|
@@ -27,6 +27,7 @@ const ContentPage = props => {
|
|
|
27
27
|
const thisPath = (0, node_path_1.resolve)('/', props.file.path);
|
|
28
28
|
const referencedFiles = props.ctx.site.files.filter(f => f.links.some(link => (0, node_path_1.resolve)('/', (0, node_path_1.dirname)(f.path), link) === thisPath));
|
|
29
29
|
const faviconUrl = (0, resourceMap_1.getFaviconUrlFrom)(props.ctx.path);
|
|
30
|
+
const customStyleUrl = props.ctx.hasCustomStyle ? (0, resourceMap_1.getCustomStyleUrlFrom)(props.ctx.path) : null;
|
|
30
31
|
return (react_1.default.createElement("html", { lang: props.lang },
|
|
31
32
|
react_1.default.createElement("head", null,
|
|
32
33
|
react_1.default.createElement("meta", { charSet: "UTF-8" }),
|
|
@@ -37,6 +38,7 @@ const ContentPage = props => {
|
|
|
37
38
|
react_1.default.createElement(Analytics_1.Analytics, { ctx: props.ctx }),
|
|
38
39
|
react_1.default.createElement("script", { src: (0, resourceMap_1.getResourceUrlFrom)(props.ctx.path, 'tailwindcss.js') }),
|
|
39
40
|
react_1.default.createElement("style", null, style_1.style),
|
|
41
|
+
customStyleUrl && react_1.default.createElement("link", { rel: "stylesheet", href: customStyleUrl }),
|
|
40
42
|
react_1.default.createElement("script", { dangerouslySetInnerHTML: {
|
|
41
43
|
__html: `
|
|
42
44
|
(function() {
|
package/dist/ssg/IndexPage.js
CHANGED
|
@@ -23,6 +23,7 @@ const IndexPage = props => {
|
|
|
23
23
|
]);
|
|
24
24
|
const allCategories = Array.from(new Set([undefined].concat(props.ctx.site.files.map(f => f.category))));
|
|
25
25
|
const faviconUrl = (0, resourceMap_1.getFaviconUrlFrom)(props.ctx.path);
|
|
26
|
+
const customStyleUrl = props.ctx.hasCustomStyle ? (0, resourceMap_1.getCustomStyleUrlFrom)(props.ctx.path) : null;
|
|
26
27
|
return (react_1.default.createElement("html", null,
|
|
27
28
|
react_1.default.createElement("head", null,
|
|
28
29
|
react_1.default.createElement("meta", { charSet: "UTF-8" }),
|
|
@@ -33,6 +34,7 @@ const IndexPage = props => {
|
|
|
33
34
|
react_1.default.createElement(Analytics_1.Analytics, { ctx: props.ctx }),
|
|
34
35
|
react_1.default.createElement("script", { src: (0, resourceMap_1.getResourceUrlFrom)(props.ctx.path, 'tailwindcss.js') }),
|
|
35
36
|
react_1.default.createElement("style", null, style_1.style),
|
|
37
|
+
customStyleUrl && react_1.default.createElement("link", { rel: "stylesheet", href: customStyleUrl }),
|
|
36
38
|
react_1.default.createElement("script", { dangerouslySetInnerHTML: {
|
|
37
39
|
__html: `
|
|
38
40
|
(function() {
|
package/dist/ssg/RootPage.js
CHANGED
|
@@ -21,6 +21,7 @@ const RootPage = props => {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
const faviconUrl = (0, resourceMap_1.getFaviconUrlFrom)(props.ctx.path);
|
|
24
|
+
const customStyleUrl = props.ctx.hasCustomStyle ? (0, resourceMap_1.getCustomStyleUrlFrom)(props.ctx.path) : null;
|
|
24
25
|
return (react_1.default.createElement("html", { lang: "en" },
|
|
25
26
|
react_1.default.createElement("head", null,
|
|
26
27
|
react_1.default.createElement("meta", { charSet: "UTF-8" }),
|
|
@@ -28,6 +29,7 @@ const RootPage = props => {
|
|
|
28
29
|
react_1.default.createElement("title", null, "CZON Multilingual Site Navigator"),
|
|
29
30
|
react_1.default.createElement("link", { rel: "icon", href: faviconUrl, type: "image/x-icon" }),
|
|
30
31
|
react_1.default.createElement("meta", { name: "description", content: "Select your preferred language to explore our content." }),
|
|
32
|
+
customStyleUrl && react_1.default.createElement("link", { rel: "stylesheet", href: customStyleUrl }),
|
|
31
33
|
react_1.default.createElement(Analytics_1.Analytics, { ctx: props.ctx }),
|
|
32
34
|
props.ctx.site.options.langs.map(lang => (react_1.default.createElement("link", { key: lang, rel: "alternate", hrefLang: lang, href: `${lang}/index.html` }))),
|
|
33
35
|
react_1.default.createElement("link", { rel: "alternate", hrefLang: "x-default", href: `${props.ctx.site.options.langs[0]}/index.html` }),
|
package/dist/ssg/resourceMap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFaviconUrlFrom = exports.getResourceUrlFrom = exports.EXTERNAL_RESOURCES = void 0;
|
|
3
|
+
exports.getCustomStyleUrlFrom = exports.getFaviconUrlFrom = exports.getResourceUrlFrom = exports.EXTERNAL_RESOURCES = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
exports.EXTERNAL_RESOURCES = [
|
|
6
6
|
{
|
|
@@ -28,4 +28,12 @@ const getFaviconUrlFrom = (path) => {
|
|
|
28
28
|
return (0, path_1.relative)((0, path_1.dirname)(path), '/favicon.ico');
|
|
29
29
|
};
|
|
30
30
|
exports.getFaviconUrlFrom = getFaviconUrlFrom;
|
|
31
|
+
/**
|
|
32
|
+
* 获取自定义样式的相对引用 URL
|
|
33
|
+
* @param path - 当前文件路径 (e.g. `/en-US/index.html`)
|
|
34
|
+
*/
|
|
35
|
+
const getCustomStyleUrlFrom = (path) => {
|
|
36
|
+
return (0, path_1.relative)((0, path_1.dirname)(path), '/style.css');
|
|
37
|
+
};
|
|
38
|
+
exports.getCustomStyleUrlFrom = getCustomStyleUrlFrom;
|
|
31
39
|
//# sourceMappingURL=resourceMap.js.map
|