Files
jiu/web/_data/docs.js
T
wangjia d256e7ac85 feat(site): 官网全新重建(App 真相源风格)+ 四档套餐 + 在线购买流
- tokens.css/site.css 逐值对齐原型设计系统,icons 雪碧图,零外链;首页/下载/帮助/法务全站重皮肤,真实截图
- 注册与登录在官网内完成(写 shared_preferences_web 兼容 localStorage,不再跳 App)
- 价格区四档:免费/标准 299/高级 599/定制;登录后标准/高级按钮变「购买 / 续费」
- 新增 /checkout/(套餐+月付年付切换)与 /license/result/(支付回跳轮询到账)
- 登录页支持 ?next= 站内回跳;二维码措辞改「扫码看详情可分享」
- 下载页构建期真实下载链接+运行时 release 刷新;旧 features 页/死 CSS/dist 产物清理

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o
2026-07-03 20:40:21 +08:00

52 lines
1.4 KiB
JavaScript

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] },
{ group: '业务操作', nums: [3, 4, 5, 6, 7, 8] },
{ group: '设置与答疑', nums: [9, 10] },
];
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 };
};