站点:纯静态 HTML + CSS + 原生 JS,零框架零构建
页面:首页 / 合作品牌 / 荣誉资质 / 客户案例 / 关于我们
内容:
- site/ 站点本体(含已压缩 webp 图片,约 4.8 MB)
- deploy/ Docker Compose / Caddy / Apache 部署配置
- _tools/ 开发自检脚本与部署脚本
- Dockerfile 自建 nginx 镜像方案
- README.md 项目文档
设计:品牌黄 #ffc107 + 白,深蓝仅用于页脚;菜单长期置顶;
交互动效只加在关键词与区块级元素上。
素材说明:原始素材(背景图/老网站/方案/荣誉资质/合作品牌,约 290 MB)
未纳入版本控制,站点使用的是 site/assets 内已处理压缩的图片。
42 lines
1.9 KiB
JavaScript
42 lines
1.9 KiB
JavaScript
// 扁平化后的路径修正:所有页面都在 site/ 根目录,去掉 ../ 前缀并修正页面间链接
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const SITE = path.join(__dirname, '..', 'site');
|
|
const PAGES = ['index.html', 'brands.html', 'honors.html', 'cases.html', 'about.html'];
|
|
|
|
for (const f of PAGES) {
|
|
const p = path.join(SITE, f);
|
|
let s = fs.readFileSync(p, 'utf8');
|
|
const before = s;
|
|
let n = 0;
|
|
|
|
// 资源路径:../assets/... -> assets/...
|
|
s = s.replace(/\.\.\/assets\//g, () => { n++; return 'assets/'; });
|
|
|
|
// 页面链接:/brands/ -> brands.html 等
|
|
const map = [
|
|
[/href="(?:\.\.\/)?(?:\/)?index\.html"/g, 'href="index.html"'],
|
|
[/href="(?:\.\.\/)?(?:\/)?brands\/?(?:index\.html)?"/g, 'href="brands.html"'],
|
|
[/href="(?:\.\.\/)?(?:\/)?honors\/?(?:index\.html)?"/g, 'href="honors.html"'],
|
|
[/href="(?:\.\.\/)?(?:\/)?cases\/?(?:index\.html)?"/g, 'href="cases.html"'],
|
|
[/href="(?:\.\.\/)?(?:\/)?about\/?(?:index\.html)?"/g, 'href="about.html"'],
|
|
[/href="(?:\.\.\/)?(?:\/)?"/g, 'href="index.html"']
|
|
];
|
|
for (const [re, to] of map) {
|
|
s = s.replace(re, () => { n++; return to; });
|
|
}
|
|
|
|
// 带锚点的链接:/cases/#realestate -> cases.html#realestate
|
|
s = s.replace(/href="(?:\.\.\/)?(?:\/)?(brands|honors|cases|about)\/#/g, (m, g) => { n++; return 'href="' + g + '.html#'; });
|
|
// 首页锚点:/about/#contact -> about.html#contact (已由上一行覆盖),/ # 保持
|
|
s = s.replace(/href="(?:\.\.\/)?(?:\/)?#/g, () => { n++; return 'href="#'; });
|
|
|
|
// 剩下的根绝对路径(漏网的)统一去掉开头斜杠
|
|
s = s.replace(/(href|src)="\/(?!\/)/g, (m, a) => { n++; return a + '="'; });
|
|
s = s.replace(/(data-(?:bg|full|src)=")\/(?!\/)/g, (m, pre) => { n++; return pre; });
|
|
|
|
if (s !== before) { fs.writeFileSync(p, s, 'utf8'); console.log('fixed ' + f + ' (' + n + ' 处)'); }
|
|
else console.log('no change ' + f);
|
|
}
|