Website: Update "On this page:" links on documentation pages. (#21580)

Changes:
- Updated how "On this page" links are generated for /docs pages.
This commit is contained in:
Eric 2024-08-26 15:32:35 -06:00 committed by GitHub
parent 9353d091fe
commit c646d0ac51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -129,13 +129,11 @@ parasails.registerPage('basic-documentation', {
// console.log(subtopics);
this.subtopics = (() => {
let subtopics = $('#body-content').find('h2.markdown-heading').map((_, el) => el.innerText);
subtopics = $.makeArray(subtopics).map((title) => {
// Removing all apostrophes from the title to keep _.kebabCase() from turning words like 'users' into 'user-s'
let kebabCaseFriendlyTitle = title.replace(/[\\']/g, '');
let subtopics = $('#body-content').find('h2.markdown-heading').map((_, el) => el);
subtopics = $.makeArray(subtopics).map((subheading) => {
return {
title,
url: '#' + _.kebabCase(kebabCaseFriendlyTitle.toLowerCase()),
title: subheading.innerText,
url: $(subheading).find('a.markdown-link').attr('href'),
};
});
return subtopics;