diff --git a/.eslintignore b/.eslintignore index 846f112d..4d6ea4e2 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,10 +1,9 @@ .git -packages/docsify-server-renderer/build.js -node_modules -build -server.js -lib -themes -build -docs/ **/*.md +build +docs +lib +node_modules +packages/docsify-server-renderer/build.js +server.js +themes diff --git a/build/html.js b/build/html.js new file mode 100644 index 00000000..d7ddf1b4 --- /dev/null +++ b/build/html.js @@ -0,0 +1,29 @@ +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); +} diff --git a/docs/helpers.md b/docs/helpers.md index 46ff81d3..27a8ced9 100644 --- a/docs/helpers.md +++ b/docs/helpers.md @@ -96,29 +96,29 @@ Only when you both set the `routerMode: 'history'` and `externalLinkTarget: '_se ### Resizing ```md - - - + + + - + ``` - - - + + + ### Customise class ```md - + ``` ### Customise ID ```md - + ``` ## Customise ID for headings diff --git a/docs/index.html b/docs/index.html index 0a83d114..abe42efb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -45,87 +45,70 @@ nav.app-nav li ul { min-width: 100px; } - + + -