chore(docs): add anchor links to documentation sub-sections (#12386)

* chore(docs): add anchor links to documentation sub-sections

* chore(docs): make entire section headings clickable as anchors
This commit is contained in:
Samuel Goodell
2017-07-18 15:16:11 -05:00
committed by Perry Govier
parent 5b9fe5e81a
commit 961bfc3ebb
2 changed files with 20 additions and 11 deletions

View File

@@ -29,6 +29,14 @@ module.exports = function jekyll(renderDocsProcessor) {
if (docs[i].href) {
docs[i].href = doc.href.replace('content/', '');
}
if (docs[i].description) {
docs[i].description = docs[i].description.replace(/(\#\#\#).+/g, (section) => {
const title = section.replace(/^(\#+\s?)/, '');
const segment = title.replace(/[^a-zA-Z0-9]+/g, '-').toLowerCase();
return `\n<h3><a class="anchor" name="${segment}" href="#${segment}">${title}</a></h3>\n`;
});
}
});
docs.push({