Skip to content

Commit ac8e3f6

Browse files
mojavelinuxrwinch
authored andcommitted
only index pages from the latest version in each release line
1 parent 33b1038 commit ac8e3f6

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

.github/actions/docsearch-config.json.hbs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
{
22
"index_name": "spring-security-docs",
33
"start_urls": [
4-
{{#each components}}
5-
{{#each versions}}
4+
{{#each latestVersions}}
65
{
76
"url": "{{{@root.site.url}}}/{{#if (eq ./activeVersionSegment '')}}(?:$|index.html$|[a-z].*){{else}}{{{./activeVersionSegment}}}/{{/if}}",
87
"extra_attributes": {
9-
"component": "{{#if (eq ./name 'ROOT')}}spring-security{{else}}{{{./name}}}{{/if}}",
8+
"component": "{{#if (eq ./name 'ROOT')}}security{{else}}{{{./name}}}{{/if}}",
109
"version": "{{{./version}}}",
11-
"version_rank": {{#if (eq this ../latest)}}1{{else}}2{{/if}}
10+
"version_rank": {{#if (eq ./activeVersionSegment '')}}1{{else}}2{{/if}}
1211
}
13-
}{{#unless (and @last @../last)}},{{/unless}}
14-
{{/each}}
12+
}{{#unless @last}},{{/unless}}
1513
{{/each}}
1614
],
1715
"sitemap_urls": [

lib/antora/extensions/publish-docsearch-config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ module.exports.register = function ({ config: { templatePath = './docsearch/conf
1818
const templateSrc = await fsp.readFile(templatePath, 'utf8')
1919
const templateBasename = ospath.basename(templatePath)
2020
const template = handlebars.compile(templateSrc, { noEscape: true, preventIndent: true, srcName: templateBasename })
21-
const components = contentCatalog.getComponentsSortedBy('name').filter((component) => component.latest.version)
21+
const latestVersions = contentCatalog.getComponentsSortedBy('name').reduce((accum, component) => {
22+
component.versions.forEach((version) => version.versionSegment !== undefined && accum.push(version))
23+
return accum
24+
}, [])
2225
const stopPages = contentCatalog.getPages((page) => {
2326
return page.out && ('page-archived' in page.asciidoc.attributes || 'page-noindex' in page.asciidoc.attributes)
2427
})
25-
const compiled = template({ components, site: playbook.site, stopPages })
28+
const compiled = template({ latestVersions, site: playbook.site, stopPages })
2629
siteCatalog.addFile({ contents: Buffer.from(compiled), out: { path: 'docsearch-config.json' } })
2730
})
2831
}

0 commit comments

Comments
 (0)