站点:纯静态 HTML + CSS + 原生 JS,零框架零构建
页面:首页 / 合作品牌 / 荣誉资质 / 客户案例 / 关于我们
内容:
- site/ 站点本体(含已压缩 webp 图片,约 4.8 MB)
- deploy/ Docker Compose / Caddy / Apache 部署配置
- _tools/ 开发自检脚本与部署脚本
- Dockerfile 自建 nginx 镜像方案
- README.md 项目文档
设计:品牌黄 #ffc107 + 白,深蓝仅用于页脚;菜单长期置顶;
交互动效只加在关键词与区块级元素上。
素材说明:原始素材(背景图/老网站/方案/荣誉资质/合作品牌,约 290 MB)
未纳入版本控制,站点使用的是 site/assets 内已处理压缩的图片。
29 lines
957 B
JavaScript
29 lines
957 B
JavaScript
// 一次性脚本:把站点内的根绝对路径改为相对路径,便于任意子目录/本地直接打开
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const SITE = path.join(__dirname, '..', 'site');
|
|
|
|
const PAGES = ['index.html',
|
|
'brands/index.html',
|
|
'honors/index.html',
|
|
'cases/index.html',
|
|
'about/index.html'];
|
|
|
|
function rewrite(file) {
|
|
const p = path.join(SITE, file);
|
|
let s = fs.readFileSync(p, 'utf8');
|
|
const depth = file.split('/').length - 1;
|
|
const up = depth === 0 ? '' : '../'.repeat(depth);
|
|
|
|
const before = s;
|
|
// href="/..." src="/..." style 中的 url('/...')
|
|
s = s.replace(/(href|src)="\/(?!\/)/g, (m, attr) => `${attr}="${up}`);
|
|
s = s.replace(/url\('\/(?!\/)/g, `url('${up}`);
|
|
s = s.replace(/(content=")\/(?=assets)/g, `$1${up}`);
|
|
if (s !== before) fs.writeFileSync(p, s, 'utf8');
|
|
console.log(`${file} depth=${depth} ${s !== before ? 'rewritten' : 'no change'}`);
|
|
}
|
|
|
|
PAGES.forEach(rewrite);
|