Minor refactor
This commit is contained in:
parent
81500eabad
commit
993a41a386
1 changed files with 5 additions and 11 deletions
16
_config.ts
16
_config.ts
|
@ -63,19 +63,13 @@ site.process([".html"], (page) => {
|
||||||
// NOTE: This is a hack to append a class to JS doctrings so that we
|
// NOTE: This is a hack to append a class to JS doctrings so that we
|
||||||
// can style them. If only the Hightlight.js plugin could be configured
|
// can style them. If only the Hightlight.js plugin could be configured
|
||||||
// to do this instead.
|
// to do this instead.
|
||||||
const codeCommentElements = page.document?.getElementsByClassName("hljs-comment");
|
page.document?.getElementsByClassName("hljs-comment").forEach((codeCommentElement) => {
|
||||||
if (codeCommentElements && codeCommentElements.length > 0) {
|
|
||||||
const docStringRegex = /^\/\*\*.*\*\/$/gsm;
|
const docStringRegex = /^\/\*\*.*\*\/$/gsm;
|
||||||
const codeDocStringElements = codeCommentElements.filter((el) => {
|
const matchResult = codeCommentElement.innerText.match(docStringRegex);
|
||||||
const matchResult = el.innerText.match(docStringRegex);
|
if (matchResult) {
|
||||||
return !!matchResult;
|
codeCommentElement.classList.add("docstring");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (codeDocStringElements.length > 0) {
|
|
||||||
codeDocStringElements.forEach((el) => {
|
|
||||||
el.classList.add("docstring");
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default site;
|
export default site;
|
||||||
|
|
Loading…
Reference in a new issue