diff --git a/config/default.json b/config/default.json index 9e03521..8124c17 100644 --- a/config/default.json +++ b/config/default.json @@ -1,14 +1,4 @@ { "indexConfig": { - // this config is used during the build to configure Zotero Bib - // component both during development and in production. Values - // listed below can be overriden in local.json and/or using - // env variables. See https://www.npmjs.com/package/config - // - // "apiAuthorityPart": undefined, - // "storeURL": undefined, - // "stylesURL": undefined, - // "translatePrefix": "", - // "translateURL": undefined } } \ No newline at end of file diff --git a/scripts/build-html.cjs b/scripts/build-html.cjs index 6ba201c..cc089ee 100644 --- a/scripts/build-html.cjs +++ b/scripts/build-html.cjs @@ -13,7 +13,9 @@ const addAnchors = html => { const $ = cheerio.load(html); const headers = $('h2, h3'); headers.map((_, element) => { - const id = element.attribs.id; + const id = element.attribs.id ?? $(element).text().replace(/[^\w\s]/g, '').trim().replace(/\s/g, '_').toLocaleLowerCase(); + element.attribs.id = id; + $('') .attr('href', '#' + id) .addClass('anchor-link')