v0.33.7
This commit is contained in:
1 parent
162e986d37
commit
6b937aaf85
54 files changed
+3527
-1325
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
// Same four compile-time substitutions as src/admin/public.rs.
|
||||
export function renderAdminIndex(root) {
|
||||
const web = path.join(root, 'src/admin/web');
|
||||
let html = fs.readFileSync(path.join(web, 'index.html'), 'utf8');
|
||||
const metrics = fs.readFileSync(path.join(web, 'partials/overview-metrics.html'), 'utf8')
|
||||
.split('<!-- RP_METRICS_SPLIT -->');
|
||||
const charts = fs.readFileSync(path.join(web, 'partials/overview-charts.html'), 'utf8')
|
||||
.split('<!-- RP_CHARTS_SPLIT -->');
|
||||
if (metrics.length !== 2 || charts.length !== 2) throw new Error('Invalid Overview partials');
|
||||
for (const [marker, text] of [
|
||||
['METRICS_MAIN', metrics[0]], ['CHARTS_MAIN', charts[0]],
|
||||
['METRICS_WEB', metrics[1]], ['CHARTS_WEB', charts[1]],
|
||||
]) {
|
||||
const token = `<!-- RP_${marker} -->`;
|
||||
if (!html.includes(token)) throw new Error(`Missing ${token}`);
|
||||
html = html.replace(token, text);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
Reference in new issue
Block a user