diff --git a/lib/index.js b/lib/index.js index 4ca10e4..e6e3e7b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -64,6 +64,7 @@ class Documentation { class Page { key title + titleKey body sections = [] #documentation @@ -77,6 +78,11 @@ class Page { this.#index = index this.#entries = entries this.title = header.text + this.titleKey = this.title + .replace(/[^a-zA-Z0-9]+/g, ' ') + .trim() + .replace(/\s+/g, '-') + .toLowerCase() } async load () { @@ -152,11 +158,7 @@ class Section { // assigns unique key value for section const prior = [ - this.page.title - .replace(/[^a-zA-Z0-9]+/g, ' ') - .trim() - .replace(/\s+/g, '-') - .toLowerCase(), + this.page.titleKey, ...this.page.sections .map(section => [section, ...section.subsections]) .flat()