Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antora/navigation-builder

Package Overview
Dependencies
Maintainers
2
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antora/navigation-builder - npm Package Compare versions

Comparing version 1.0.0-alpha.6 to 1.0.0-alpha.7

32

lib/build-navigation.js

@@ -23,11 +23,15 @@ 'use strict'

* that provides access to the virtual files in the site.
* @param {Object} [asciidocConfig={}] - AsciiDoc processor configuration options. Extensions are not propagated.
* Sets the relativizePageRefs option to false before passing to the loadAsciiDoc function.
* @param {Object} [asciidocConfig.attributes={}] - Shared AsciiDoc attributes to assign to the document.
*
* @returns {NavigationCatalog} A navigation catalog built from the navigation
* files in the content catalog.
* @returns {NavigationCatalog} A navigation catalog built from the navigation files in the content catalog.
*/
function buildNavigation (contentCatalog) {
const navFiles = contentCatalog.findBy({ family: 'navigation' }) || []
if (navFiles.length === 0) return new NavigationCatalog()
function buildNavigation (contentCatalog, asciidocConfig = {}) {
const navFiles = contentCatalog.findBy({ family: 'navigation' })
if (!(navFiles && navFiles.length)) return new NavigationCatalog()
asciidocConfig = Object.assign({}, asciidocConfig, { relativizePageRefs: false })
delete asciidocConfig.extensions
return navFiles
.map((navFile) => loadNavigationFile(navFile, {}, contentCatalog))
.map((navFile) => loadNavigationFile(navFile, contentCatalog, asciidocConfig))
.reduce((accum, treeSet) => accum.concat(treeSet), [])

@@ -40,12 +44,10 @@ .reduce((catalog, { component, version, tree }) => {

function loadNavigationFile (navFile, customAttrs, contentCatalog) {
function loadNavigationFile (navFile, contentCatalog, asciidocConfig) {
const lists = loadAsciiDoc(navFile, contentCatalog, asciidocConfig).blocks.filter((b) => b.context === 'ulist')
if (!lists.length) return []
const { src: { component, version }, nav: { index } } = navFile
const lists = loadAsciiDoc(navFile, customAttrs, contentCatalog, { relativizePageRefs: false }).blocks.filter(
(block) => block.context === 'ulist'
)
if (lists.length === 0) return []
return lists.map((list, idx) => {
const tree = buildNavigationTree(list.getTitle(), list)
tree.root = true
tree.order = idx === 0 ? index : parseFloat((index + idx / lists.length).toFixed(4))
tree.order = idx ? parseFloat((index + idx / lists.length).toFixed(4)) : index
return { component, version, tree }

@@ -56,4 +58,4 @@ })

function getChildList (node) {
const block0 = node.blocks[0]
if (block0 && block0.context === 'ulist') return block0
const firstBlock = node.getBlocks()[0]
if (firstBlock && firstBlock.context === 'ulist') return firstBlock
}

@@ -65,3 +67,3 @@

if (list) {
entry.items = list.blocks.map((item) => buildNavigationTree(item.$text(), getChildList(item)))
entry.items = list.getItems().map((item) => buildNavigationTree(item.getText(), getChildList(item)))
}

@@ -68,0 +70,0 @@

{
"name": "@antora/navigation-builder",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.7",
"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.0-alpha.6"
"@antora/asciidoc-loader": "1.0.0-alpha.7"
},

@@ -21,0 +21,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc