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

@antora/page-composer

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/page-composer - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

42

lib/create-page-composer.js

@@ -36,6 +36,8 @@ 'use strict'

const layouts = uiCatalog.findByType('layout').reduce((accum, file) => {
accum[file.stem] = handlebars.compile(file.contents.toString(), HANDLEBARS_COMPILE_OPTIONS)
return accum
}, {})
const layouts = uiCatalog
.findByType('layout')
.reduce(
(accum, file) => accum.set(file.stem, handlebars.compile(file.contents.toString(), HANDLEBARS_COMPILE_OPTIONS)),
new Map()
)

@@ -69,3 +71,3 @@ return createPageComposerInternal(buildSiteUiModel(playbook, contentCatalog), env, layouts)

let layout = uiModel.page.layout
if (!(layout in layouts)) {
if (!layouts.has(layout)) {
if (layout === '404') throw new Error('404 layout not found')

@@ -75,3 +77,3 @@ const defaultLayout = uiModel.site.ui.defaultLayout

throw new Error(`${layout} layout not found`)
} else if (!(defaultLayout in layouts)) {
} else if (!layouts.has(defaultLayout)) {
throw new Error(`Neither ${layout} layout or fallback ${defaultLayout} layout found`)

@@ -84,3 +86,3 @@ }

// QUESTION should we call trim() on result?
file.contents = Buffer.from(layouts[layout](uiModel))
file.contents = Buffer.from(layouts.get(layout)(uiModel))
return file

@@ -149,3 +151,3 @@ }

const navigation = navigationCatalog.getMenu(componentName, version) || []
const breadcrumbs = getBreadcrumbs(url, navigation)
const title = asciidoc.doctitle

@@ -155,3 +157,3 @@ const model = {

layout: pageAttributes.layout || site.ui.defaultLayout,
title: asciidoc.doctitle,
title,
url,

@@ -162,3 +164,3 @@ description: attributes.description,

component,
componentVersion: component.versions.find((candidate) => candidate.version === version),
componentVersion: getComponentVersion(component.versions, version),
version,

@@ -168,3 +170,4 @@ module: file.src.module,

navigation,
breadcrumbs,
// QUESTION should we filter out component start page?
breadcrumbs: getBreadcrumbs(url, title, navigation),
editUrl: file.src.editUrl,

@@ -181,13 +184,16 @@ home: url === site.homeUrl,

function getBreadcrumbs (matchUrl, menu) {
function getBreadcrumbs (pageUrl, pageTitle, menu) {
for (let i = 0, numTrees = menu.length; i < numTrees; i++) {
const breadcrumbs = findBreadcrumbPath(matchUrl, menu[i])
const breadcrumbs = findBreadcrumbPath(pageUrl, menu[i])
if (breadcrumbs) return breadcrumbs
}
return []
return pageTitle ? [{ content: pageTitle, url: pageUrl, urlType: 'internal', discrete: true }] : []
}
function findBreadcrumbPath (matchUrl, currentItem, currentPath = []) {
if (currentItem.url === matchUrl && currentItem.urlType === 'internal') {
return currentPath.concat(currentItem)
if (currentItem.urlType === 'internal') {
const currentItemUrl = currentItem.hash
? currentItem.url.substr(0, currentItem.url.length - currentItem.hash.length)
: currentItem.url
if (currentItemUrl === matchUrl) return currentPath.concat(currentItem)
}

@@ -208,2 +214,6 @@ const items = currentItem.items

function getComponentVersion (versions, currentVersion) {
return versions.find((candidate) => candidate.version === currentVersion)
}
// QUESTION should this go in ContentCatalog?

@@ -210,0 +220,0 @@ // should it accept module and relative instead of pageSrc?

{
"name": "@antora/page-composer",
"version": "1.0.0",
"version": "1.0.1",
"description": "Wraps the embeddable HTML contents of each page file from the content catalog in a page layout to yield standalone pages in an Antora documentation pipeline.",

@@ -18,5 +18,5 @@ "license": "MPL-2.0",

"dependencies": {
"@antora/content-classifier": "1.0.0",
"@antora/content-classifier": "1.0.1",
"handlebars": "^4.0.11",
"require-from-string": "^2.0.1"
"require-from-string": "^2.0.2"
},

@@ -23,0 +23,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