Files
maoxiang d36050cff7 初始化仓库
初始化仓库
2026-09-09 13:19:09 +08:00

19 lines
814 B
JavaScript

const fs = require('fs');
let c = fs.readFileSync('src/index.html', 'utf8');
// 1. modules 兜底为空列表
c = c.replace(
' <div class="homepage">\n <th:block th:each="mod : ${theme.config.homepage.modules}">',
' <div class="homepage">\n <th:block th:with="modules = ${theme.config.homepage?.modules ?: #lists.toList()}">\n <th:block th:each="mod : ${modules}">'
);
c = c.replace(
' </th:block>\n\n </th:block>\n\n <section class="section browse"',
' </th:block>\n\n </th:block>\n </th:block>\n\n <section class="section browse"'
);
// 2. 所有 th:each="x : ${mod.xxx}" 加 ?: #lists.toList() 兜底
c = c.replace(/th:each="([^"]+) : \$\{mod\.(\w+)\}"/g, 'th:each="$1 : ${mod.$2 ?: #lists.toList()}"');
fs.writeFileSync('src/index.html', c);
console.log('done');