Add a title to each page
This commit is contained in:
parent
97583341a7
commit
8a681e8523
@ -2,11 +2,13 @@ const { mkdir, rmdir, readdir, stat, readFile, writeFile, copyFile } = require('
|
||||
const { join, dirname, parse, format } = require('path');
|
||||
const marked = require('./');
|
||||
const { highlight, highlightAuto } = require('highlight.js');
|
||||
const titleize = require('titleize');
|
||||
const cwd = process.cwd();
|
||||
const inputDir = join(cwd, 'docs');
|
||||
const outputDir = join(cwd, 'public');
|
||||
const templateFile = join(inputDir, '_document.html');
|
||||
const isUppercase = str => /[A-Z_]+/.test(str);
|
||||
const getTitle = str => str === 'INDEX' ? '' : titleize(str.replace(/_/g, ' ')) + ' - ';
|
||||
|
||||
async function init() {
|
||||
console.log('Cleaning up output directory ' + outputDir);
|
||||
@ -41,7 +43,9 @@ async function build(currentDir, tmpl) {
|
||||
return highlight(lang, code).value;
|
||||
}
|
||||
});
|
||||
contents = tmpl.replace('<!--{{content}}-->', html);
|
||||
contents = tmpl
|
||||
.replace('<!--{{title}}-->', getTitle(parsed.name))
|
||||
.replace('<!--{{content}}-->', html);
|
||||
parsed.ext = '.html';
|
||||
parsed.name = parsed.name.toLowerCase();
|
||||
delete parsed.base;
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Marked Documentation</title>
|
||||
<title><!--{{title}}-->Marked Documentation</title>
|
||||
<link rel="stylesheet" href="/css/style.css" type="text/css" />
|
||||
<link rel="stylesheet" href="/css/hljs-github.css" type="text/css" />
|
||||
</head>
|
||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -3305,6 +3305,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"titleize": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/titleize/-/titleize-2.1.0.tgz",
|
||||
"integrity": "sha512-m+apkYlfiQTKLW+sI4vqUkwMEzfgEUEYSqljx1voUE3Wz/z1ZsxyzSxvH2X8uKVrOp7QkByWt0rA6+gvhCKy6g==",
|
||||
"dev": true
|
||||
},
|
||||
"to-fast-properties": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
||||
|
@ -52,6 +52,7 @@
|
||||
"rollup-plugin-babel": "^4.4.0",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-license": "^2.1.0",
|
||||
"titleize": "^2.1.0",
|
||||
"uglify-js": "^3.10.0",
|
||||
"vuln-regex-detector": "^1.3.0"
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user