@antora/navigation-builder
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -51,3 +51,3 @@ 'use strict' | ||
return lists.map((list, idx) => { | ||
const tree = buildNavigationTree(list.getTitle(), list) | ||
const tree = buildNavigationTree(list.getTitle(), list.getItems()) | ||
tree.root = true | ||
@@ -59,19 +59,30 @@ tree.order = idx ? parseFloat((index + idx / lists.length).toFixed(4)) : index | ||
function getChildList (node) { | ||
let candidate = node.getBlocks()[0] | ||
let context | ||
if ( | ||
candidate && | ||
((context = candidate.getContext()) === 'ulist' || | ||
(context === 'open' && (candidate = candidate.getBlocks()[0]) && candidate.getContext() === 'ulist')) | ||
) { | ||
return candidate | ||
function getChildListItems (listItem) { | ||
const blocks = listItem.getBlocks() | ||
const candidate = blocks[0] | ||
if (candidate) { | ||
if (blocks.length === 1 && candidate.getContext() === 'ulist') { | ||
return candidate.getItems() | ||
} else { | ||
let context | ||
return blocks.reduce((accum, block) => { | ||
if ( | ||
(context = block.getContext()) === 'ulist' || | ||
(context === 'open' && (block = block.getBlocks()[0]) && block.getContext() === 'ulist') | ||
) { | ||
accum.push(...block.getItems()) | ||
} | ||
return accum | ||
}, []) | ||
} | ||
} else { | ||
return [] | ||
} | ||
} | ||
function buildNavigationTree (formattedContent, list) { | ||
function buildNavigationTree (formattedContent, items) { | ||
const entry = formattedContent ? partitionContent(formattedContent) : {} | ||
if (list) { | ||
entry.items = list.getItems().map((item) => buildNavigationTree(item.getText(), getChildList(item))) | ||
if (items.length) { | ||
entry.items = items.map((item) => buildNavigationTree(item.getText(), getChildListItems(item))) | ||
} | ||
@@ -78,0 +89,0 @@ |
{ | ||
"name": "@antora/navigation-builder", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"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.2" | ||
"@antora/asciidoc-loader": "1.0.3" | ||
}, | ||
@@ -21,0 +21,0 @@ "engines": { |
6923
140
+ Added@antora/asciidoc-loader@1.0.3(transitive)
- Removed@antora/asciidoc-loader@1.0.2(transitive)