Skip to content

Commit

Permalink
add title key generation for a page
Browse files Browse the repository at this point in the history
  • Loading branch information
derekwolpert committed Sep 28, 2022
1 parent 8dfad14 commit 9bfd8c0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Documentation {
class Page {
key
title
titleKey
body
sections = []
#documentation
Expand All @@ -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 () {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9bfd8c0

Please sign in to comment.