@antora/navigation-builder
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -16,3 +16,3 @@ 'use strict' | ||
* unordered lists, which are used to build the navigation trees. It then | ||
* combines those trees in sorted order as a navigation menu, which gets | ||
* combines those trees in sorted order as a navigation set, which gets | ||
* stored in the navigation catalog by component/version pair. | ||
@@ -31,3 +31,3 @@ * | ||
function buildNavigation (contentCatalog, asciidocConfig = {}) { | ||
const navFiles = contentCatalog.findBy({ family: 'navigation' }) | ||
const navFiles = contentCatalog.findBy({ family: 'nav' }) | ||
if (!(navFiles && navFiles.length)) return new NavigationCatalog() | ||
@@ -38,5 +38,5 @@ asciidocConfig = Object.assign({}, asciidocConfig, { relativizePageRefs: false }) | ||
.map((navFile) => loadNavigationFile(navFile, contentCatalog, asciidocConfig)) | ||
.reduce((accum, treeSet) => accum.concat(treeSet), []) | ||
.reduce((accum, trees) => accum.concat(trees), []) | ||
.reduce((catalog, { component, version, tree }) => { | ||
catalog.addTree(component, version, tree) | ||
contentCatalog.getComponentVersion(component, version).navigation = catalog.addTree(component, version, tree) | ||
return catalog | ||
@@ -43,0 +43,0 @@ }, new NavigationCatalog()) |
'use strict' | ||
const $menus = Symbol('menus') | ||
const $sets = Symbol('sets') | ||
const $generateId = Symbol('generateId') | ||
@@ -8,3 +8,3 @@ | ||
constructor () { | ||
this[$menus] = {} | ||
this[$sets] = {} | ||
} | ||
@@ -14,22 +14,16 @@ | ||
const id = this[$generateId](component, version) | ||
const menu = id in this[$menus] ? this[$menus][id] : (this[$menus][id] = []) | ||
const navigation = id in this[$sets] ? this[$sets][id] : (this[$sets][id] = []) | ||
// NOTE retain order on insert | ||
const insertIdx = menu.findIndex((candidate) => candidate.order >= tree.order) | ||
~insertIdx ? menu.splice(insertIdx, 0, tree) : menu.push(tree) | ||
const insertIdx = navigation.findIndex((candidate) => candidate.order >= tree.order) | ||
~insertIdx ? navigation.splice(insertIdx, 0, tree) : navigation.push(tree) | ||
return navigation | ||
} | ||
//getMenus () { | ||
// return _.map(this[$menus], (trees, id) => { | ||
// const [component, version] = id.split(':') | ||
// return { component, version, trees } | ||
// }) | ||
//} | ||
getMenu (component, version) { | ||
getNavigation (component, version) { | ||
const id = this[$generateId](component, version) | ||
return this[$menus][id] | ||
return this[$sets][id] | ||
} | ||
[$generateId] (component, version) { | ||
return component + ':' + version | ||
return version + '@' + component | ||
} | ||
@@ -36,0 +30,0 @@ } |
{ | ||
"name": "@antora/navigation-builder", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Builds a navigation catalog from navigation files for adding site navigation to pages in an Antora documentation pipeline.", | ||
@@ -18,3 +18,3 @@ "license": "MPL-2.0", | ||
"dependencies": { | ||
"@antora/asciidoc-loader": "1.0.3" | ||
"@antora/asciidoc-loader": "1.1.0" | ||
}, | ||
@@ -21,0 +21,0 @@ "engines": { |
6844
135
+ Added@antora/asciidoc-loader@1.1.0(transitive)
- Removed@antora/asciidoc-loader@1.0.3(transitive)