mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
- Create template for generating multiple `index.html` files (root and `/docs/`) - Add nunjucks dependency - Append “(Preview)” to document title for easier identification of local preview tabs/windows (preview only) - Add custom plugin to fix preview paths to `/docs` resources in markdown (preview only) - Add front-matter plugin to `/docs/index.html` (missing in previous file, required for front-matter demo in docs) - Add “build:html” npm script - Fix preview paths to `/docs` resources in `index.html` files (preview only) - Remove “Powered by docsify” from footer - Remove “Vercel has given us a Pro account” from footer (acknowledgement provided via the “Special Thanks” section in README) - Move “Edit Document” link from top-left to bottom-right of page - Refactor package.json script (reorder) - Refactor `.eslintignore` file (reorder and remove duplicate entries)
30 lines
853 B
JavaScript
30 lines
853 B
JavaScript
const fs = require('fs');
|
|
const nunjucks = require('nunjucks');
|
|
const path = require('path');
|
|
const prettier = require('prettier');
|
|
|
|
const renderJobs = [
|
|
// Preview index.html
|
|
{
|
|
isProduction: false,
|
|
inputPath: path.resolve(__dirname, '../src/html/index.njk'),
|
|
outputPath: path.resolve(__dirname, '../index.html'),
|
|
},
|
|
// Production index.html
|
|
{
|
|
isProduction: true,
|
|
inputPath: path.resolve(__dirname, '../src/html/index.njk'),
|
|
outputPath: path.resolve(__dirname, '../docs/index.html'),
|
|
},
|
|
];
|
|
|
|
for (const job of renderJobs) {
|
|
console.log(`[Build HTML] ${job.outputPath}`);
|
|
|
|
const template = fs.readFileSync(job.inputPath, 'utf8').toString();
|
|
const html = nunjucks.renderString(template, job);
|
|
const htmlFormatted = prettier.format(html, { parser: 'html' });
|
|
|
|
fs.writeFileSync(job.outputPath, htmlFormatted);
|
|
}
|