refactor(web): 营销站重构为 Eleventy SSG,内容迁移至 Markdown
- 引入 Eleventy 静态站点生成器,页面统一使用 Nunjucks 模板 - base.njk 提供公共 nav / footer / CSS,消除三个页面间的重复代码 - 抽取 color.css(设计 token)+ style.css(公共组件 + utility 类) - index.njk:首页迁移,用 utility class 替换大量页面私有 CSS - download.njk:下载页重构,版本号/更新日志从 CHANGELOG.md 构建时解析,OS 自动识别 - docs.njk:文档页重构,12 章内容从 web/content/docs.md 构建时渲染,三列布局保留 - docs.css 单独提取,docs 专有样式不污染公共 CSS - 内容面向非技术用户重写,去除技术术语和内部路径引用 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function() {
|
||||
const raw = fs.readFileSync(path.join(__dirname, '../../CHANGELOG.md'), 'utf8');
|
||||
const lines = raw.split('\n');
|
||||
const versions = [];
|
||||
let current = null;
|
||||
let currentSection = null;
|
||||
|
||||
for (const line of lines) {
|
||||
const versionMatch = line.match(/^## \[([^\]]+)\] - (\d{4}-\d{2}-\d{2})/);
|
||||
if (versionMatch) {
|
||||
if (current) versions.push(current);
|
||||
if (versions.length >= 3) break;
|
||||
current = { version: versionMatch[1], date: versionMatch[2], sections: [], intro: '' };
|
||||
currentSection = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
const sectionMatch = line.match(/^### (.+)/);
|
||||
if (sectionMatch && current) {
|
||||
currentSection = { type: sectionMatch[1], items: [] };
|
||||
current.sections.push(currentSection);
|
||||
continue;
|
||||
}
|
||||
|
||||
const itemMatch = line.match(/^- (.+)/);
|
||||
if (itemMatch && current) {
|
||||
if (currentSection) {
|
||||
currentSection.items.push(itemMatch[1]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Free-form text before first section (e.g. v1.0.0 intro paragraph)
|
||||
if (line.trim() && current && !currentSection && !line.startsWith('#')) {
|
||||
current.intro = current.intro ? current.intro + ' ' + line.trim() : line.trim();
|
||||
}
|
||||
}
|
||||
if (current && versions.length < 3) versions.push(current);
|
||||
|
||||
return versions;
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const md = require('markdown-it')({ html: false, breaks: false, linkify: false });
|
||||
|
||||
const TOC_GROUPS = [
|
||||
{ group: '快速开始', nums: [1, 2, 3] },
|
||||
{ group: '业务操作', nums: [4, 5, 6, 7, 8, 9] },
|
||||
{ group: '基础设置', nums: [10, 11, 12] },
|
||||
];
|
||||
|
||||
module.exports = function() {
|
||||
const raw = fs.readFileSync(path.join(__dirname, '../content/docs.md'), 'utf8');
|
||||
const lines = raw.split('\n');
|
||||
|
||||
// Split into chapters by "## {n}. {title}" headings
|
||||
const chapters = [];
|
||||
let current = null;
|
||||
|
||||
for (const line of lines) {
|
||||
const match = line.match(/^## (\d+)\. (.+)/);
|
||||
if (match) {
|
||||
if (current) chapters.push(current);
|
||||
const num = parseInt(match[1], 10);
|
||||
current = { num, id: 'ch-' + num, title: match[2].trim(), bodyLines: [] };
|
||||
} else if (current) {
|
||||
current.bodyLines.push(line);
|
||||
}
|
||||
}
|
||||
if (current) chapters.push(current);
|
||||
|
||||
// Render each chapter's body to HTML
|
||||
const rendered = chapters.map(ch => ({
|
||||
num: ch.num,
|
||||
id: ch.id,
|
||||
title: ch.title,
|
||||
html: md.render(ch.bodyLines.join('\n')),
|
||||
}));
|
||||
|
||||
// Build TOC
|
||||
const chapterMap = {};
|
||||
rendered.forEach(ch => { chapterMap[ch.num] = ch; });
|
||||
|
||||
const toc = TOC_GROUPS.map(g => ({
|
||||
group: g.group,
|
||||
items: g.nums
|
||||
.filter(n => chapterMap[n])
|
||||
.map(n => ({ id: chapterMap[n].id, num: n, title: chapterMap[n].title })),
|
||||
}));
|
||||
|
||||
return { toc, chapters: rendered };
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "岩美酒库管理系统",
|
||||
"tagline": "为酒行与酒店设计的库存管理平台",
|
||||
"copyright": "© 2026 岩美科技 · 保留所有权利",
|
||||
"icp": "沪 ICP 备 2026000000 号 · 沪公网安备 31010000000000 号",
|
||||
"support": {
|
||||
"email": "support@yanmei.app",
|
||||
"phone": "400-880-8888"
|
||||
},
|
||||
"appUrl": "/app/",
|
||||
"lucideVersion": "0.469.0"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const md = require('markdown-it')({ html: false, breaks: false });
|
||||
|
||||
module.exports = function() {
|
||||
const content = fs.readFileSync(path.join(__dirname, '../content/system-requirements.md'), 'utf8');
|
||||
return md.render(content);
|
||||
};
|
||||
Reference in New Issue
Block a user