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 3.0.3 to 3.1.0

39

lib/create-page-composer.js
'use strict'
const { buildBaseUiModel, buildUiModel } = require('./build-ui-model')
const handlebars = require('handlebars')
const Handlebars = require('handlebars')
const logger = require('./logger')

@@ -29,2 +29,3 @@ const relativize = require('./helpers/relativize')

function createPageComposer (playbook, contentCatalog, uiCatalog) {
const handlebars = Handlebars.create()
handlebars.registerHelper('relativize', relativize)

@@ -39,12 +40,9 @@ handlebars.registerHelper('resolvePage', resolvePage)

uiCatalog.findByType('partial').forEach(({ stem, contents }) => handlebars.registerPartial(stem, contents.toString()))
const layouts = uiCatalog
.findByType('layout')
.reduce(
(accum, { path: srcName, stem, contents }) =>
accum.set(stem, handlebars.compile(contents.toString(), { preventIndent: true, srcName })),
new Map()
)
const composePage = createPageComposerInternal(buildBaseUiModel(playbook, contentCatalog), layouts)
const create404Page = (siteAsciiDocConfig) => {
return composePage({
handlebars.layouts = uiCatalog.findByType('layout').reduce((accum, { path: srcName, stem, contents }) => {
accum[stem] = handlebars.compile(contents.toString(), { preventIndent: true, srcName })
return accum
}, {})
const composePage = createPageComposerInternal(handlebars, buildBaseUiModel(playbook, contentCatalog))
const create404Page = (siteAsciiDocConfig) =>
composePage({
asciidoc: siteAsciiDocConfig,

@@ -57,7 +55,6 @@ mediaType: 'text/html',

})
}
return Object.assign(composePage, { composePage, create404Page })
return Object.assign(composePage, { composePage, create404Page, handlebars })
}
function createPageComposerInternal (baseUiModel, layouts) {
function createPageComposerInternal ({ layouts }, baseUiModel) {
/**

@@ -85,3 +82,3 @@ * Wraps the embeddable HTML contents of the specified file in a page layout.

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

@@ -91,6 +88,10 @@ const defaultLayout = uiModel.site.ui.defaultLayout

throw new Error(`${layout} layout not found`)
} else if (!layouts.has(defaultLayout)) {
} else if (!(defaultLayout in layouts)) {
throw new Error(`Neither ${layout} layout or fallback ${defaultLayout} layout found`)
}
logger.warn({ file: file.src }, "page layout '%s' specified by page not found; using default layout", layout)
logger.warn(
{ file: file.src },
'Page layout specified by page not found: %s (reverting to default layout)',
layout
)
layout = defaultLayout

@@ -100,3 +101,3 @@ }

try {
file.contents = Buffer.from(layouts.get(layout)(uiModel))
file.contents = Buffer.from(layouts[layout](uiModel))
} catch (err) {

@@ -110,3 +111,3 @@ throw transformHandlebarsError(err, layout)

function transformHandlebarsError ({ message, stack }, layout) {
const m = stack.match(/^ *at Object\.ret \[as (.+?)\]/m)
const m = stack.match(/\n *at Object\.ret \[as (.+?)\].*\n *at Object\.invokePartialWrapper \[as invokePartial\]/)
const templatePath = `${m ? 'partials/' + m[1] : 'layouts/' + layout}.hbs`

@@ -113,0 +114,0 @@ const err = new Error(`${message}${~message.indexOf('\n') ? '\n^ ' : ' '}in UI template ${templatePath}`)

{
"name": "@antora/page-composer",
"version": "3.0.3",
"version": "3.1.0",
"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.",

@@ -17,4 +17,10 @@ "license": "MPL-2.0",

"main": "lib/index.js",
"exports": {
".": "./lib/index.js",
"./build-ui-model": "./lib/build-ui-model.js",
"./lib/build-ui-model": "./lib/build-ui-model.js",
"./package.json": "./package.json"
},
"dependencies": {
"@antora/logger": "3.0.3",
"@antora/logger": "3.1.0",
"handlebars": "~4.7",

@@ -24,3 +30,3 @@ "require-from-string": "~2.0"

"engines": {
"node": ">=12.21.0"
"node": ">=16.0.0"
},

@@ -27,0 +33,0 @@ "files": [

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