初始化仓库
初始化仓库
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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');
|
||||
Reference in New Issue
Block a user