Skip to content

Commit 89d91ae

Browse files
authored
fix cheat sheet toc (#330)
A recent change to how the titles for Page Contents are generated created a bug in the Cheat Sheet where the titles were not displayed in the TOC, because the code was not correctly handling headings that contain links. We don't typically use links in headings in the docs (in fact it should possibly be a style guide recommendation to NOT use links in headings in other docs) but the cheat sheet makes extensive use of this to provide links to the relevant sections of the Cypher Manual. This PR fixes the issue.
1 parent 91e28e6 commit 89d91ae

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

preview-src/ui-model.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ page:
314314
class: 'aura-dbp'
315315
- name: 'AuraDB Virtual Dedicated Cloud'
316316
class: 'aura-dbe'
317+
- name: 'AuraDB Business Critical'
318+
class: 'aura-dbc'
317319
- name: 'AuraDS Professional'
318320
class: 'aura-dsp'
319321
- name: 'AuraDS Enterprise'

src/js/02-on-this-page.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@
3030
var list = headings.reduce(function (accum, heading) {
3131
var link = document.createElement('a')
3232
var headingClone = heading.cloneNode(true)
33-
headingClone.querySelectorAll('div, a').forEach(function (el) { el.remove() })
34-
link.innerHTML = headingClone.innerHTML
33+
// console.log(headingClone)
34+
headingClone.querySelectorAll('div, a.anchor').forEach(function (el) { el.remove() })
35+
if (headingClone.querySelector('a')) {
36+
link.textContent = headingClone.textContent
37+
} else {
38+
link.innerHTML = headingClone.innerHTML
39+
}
3540
links[(link.href = '#' + heading.id)] = link
3641
var listItem = document.createElement('li')
3742
listItem.dataset.level = parseInt(heading.nodeName.slice(1)) - 1

0 commit comments

Comments
 (0)