[0.1.5] fix slugs and sitemap generation
This commit is contained in:
parent
6565b78ac1
commit
7991d78e1c
24
compile.js
24
compile.js
|
@ -38,8 +38,28 @@ if(Process.argv.length < 4 && require.main === module) {
|
|||
}
|
||||
|
||||
function markup(input, options) {
|
||||
var usedSlugs = {};
|
||||
let tableOfContents = new Remarkable().use(TOCGenerator.plugin(options)).render(input);
|
||||
let output = new Remarkable().use(RemarkableHeaderIDs()).render("# Table of contents:\n"+tableOfContents.content+"\n\n"+input);
|
||||
let output = new Remarkable().use(
|
||||
RemarkableHeaderIDs({
|
||||
levels: [1,2,3,4,5,6],
|
||||
anchorClassName: "header-anchor",
|
||||
anchorText: "#",
|
||||
headerId: function(slug) {
|
||||
if(usedSlugs[slug] > 0) {
|
||||
const out_ = `${slug}-${usedSlugs[slug]}`;
|
||||
usedSlugs[slug] = usedSlugs[slug] + 1;
|
||||
return out_;
|
||||
} else {
|
||||
if(!usedSlugs.hasOwnProperty(slug)) {
|
||||
usedSlugs[slug] = 0;
|
||||
}
|
||||
usedSlugs[slug] = usedSlugs[slug] + 1;
|
||||
return slug;
|
||||
}
|
||||
}
|
||||
})
|
||||
).render("# Table of contents:\n"+tableOfContents.content+"\n\n"+input);
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@ -67,7 +87,7 @@ function format(data, name) {
|
|||
"$1$2"
|
||||
)
|
||||
.replace( /* multitag suffix fix for special characters. */
|
||||
/(<\/(?:a|code)>)\n\t*([.)\];:,?!+-])/g,
|
||||
/(<\/(?:a|code)>)\n\t*([.)\];:,?!+\-'])/g,
|
||||
"$1$2"
|
||||
)
|
||||
.replace( /* fix tag attached to word and not whitespace */
|
||||
|
|
|
@ -45,9 +45,10 @@ ${outputTemp}</urlset>
|
|||
}
|
||||
|
||||
function makeSitemapChunk(file, outputDir) {
|
||||
var file = file.replace(".md", ".html");
|
||||
outputTemp = outputTemp.concat( /* eslint-disable indent */
|
||||
` <url>
|
||||
<loc>https://${targetDomain}${rootPrefix}${file.replace(outputDir, "")}</loc>
|
||||
<loc>https://${targetDomain}${rootPrefix}${file.replace(outputDir, "").replace(".md", ".html")}</loc>
|
||||
<lastmod>${Filesystem.statSync(file).mtime.toISOString().substring(0, 10)}</lastmod>
|
||||
</url>
|
||||
`
|
||||
|
|
6
ymake.js
6
ymake.js
|
@ -73,9 +73,11 @@ Filesystem.globSync(`${SRC_DIRS}/**/*.css`).forEach(function(file) {
|
|||
Filesystem.writeFileSync(Path.normalize(BUILD_DIR+"/sitemap.xml"),
|
||||
require("./sitemap-gen.js")(
|
||||
MARKDOWN_L.map(function(filename){
|
||||
return Path.dirname(filename).replace(/\\/g, "/") + "/" + Path.basename(filename);
|
||||
return Path.dirname(filename)
|
||||
.replace(Path.normalize(SRC_DIRS), Path.normalize(BUILD_DIR))
|
||||
.replace(/\\/g, "/") + "/" + Path.basename(filename, ".md") + ".html";
|
||||
}),
|
||||
Path.normalize(SRC_DIRS)
|
||||
Path.normalize(BUILD_DIR)
|
||||
)
|
||||
);
|
||||
console.log(`SMAP: ${Path.normalize(BUILD_DIR+"/sitemap.xml")}`);
|
||||
|
|
Loading…
Reference in New Issue