only index pages from the latest version in each release line

This commit is contained in:
Dan Allen 2023-01-11 03:04:03 -07:00 committed by Rob Winch
parent 33b1038eb6
commit ac8e3f6810
2 changed files with 9 additions and 8 deletions

View File

@ -1,17 +1,15 @@
{
"index_name": "spring-security-docs",
"start_urls": [
{{#each components}}
{{#each versions}}
{{#each latestVersions}}
{
"url": "{{{@root.site.url}}}/{{#if (eq ./activeVersionSegment '')}}(?:$|index.html$|[a-z].*){{else}}{{{./activeVersionSegment}}}/{{/if}}",
"extra_attributes": {
"component": "{{#if (eq ./name 'ROOT')}}spring-security{{else}}{{{./name}}}{{/if}}",
"component": "{{#if (eq ./name 'ROOT')}}security{{else}}{{{./name}}}{{/if}}",
"version": "{{{./version}}}",
"version_rank": {{#if (eq this ../latest)}}1{{else}}2{{/if}}
"version_rank": {{#if (eq ./activeVersionSegment '')}}1{{else}}2{{/if}}
}
}{{#unless (and @last @../last)}},{{/unless}}
{{/each}}
}{{#unless @last}},{{/unless}}
{{/each}}
],
"sitemap_urls": [

View File

@ -18,11 +18,14 @@ module.exports.register = function ({ config: { templatePath = './docsearch/conf
const templateSrc = await fsp.readFile(templatePath, 'utf8')
const templateBasename = ospath.basename(templatePath)
const template = handlebars.compile(templateSrc, { noEscape: true, preventIndent: true, srcName: templateBasename })
const components = contentCatalog.getComponentsSortedBy('name').filter((component) => component.latest.version)
const latestVersions = contentCatalog.getComponentsSortedBy('name').reduce((accum, component) => {
component.versions.forEach((version) => version.versionSegment !== undefined && accum.push(version))
return accum
}, [])
const stopPages = contentCatalog.getPages((page) => {
return page.out && ('page-archived' in page.asciidoc.attributes || 'page-noindex' in page.asciidoc.attributes)
})
const compiled = template({ components, site: playbook.site, stopPages })
const compiled = template({ latestVersions, site: playbook.site, stopPages })
siteCatalog.addFile({ contents: Buffer.from(compiled), out: { path: 'docsearch-config.json' } })
})
}