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-beta.3 to 1.0.0-rc.1

33

lib/create-page-composer.js

@@ -25,6 +25,7 @@ 'use strict'

* that provides access to the UI files for the site.
* @param {Object} [env=process.env] - A map of environment variables.
* @returns {Function} A function to compose a page (i.e., wrap the embeddable
* HTML contents in a standalone page layout).
*/
function createPageComposer (playbook, contentCatalog, uiCatalog) {
function createPageComposer (playbook, contentCatalog, uiCatalog, env = process.env) {
uiCatalog

@@ -41,6 +42,6 @@ .findByType('helper')

return createPageComposerInternal(buildSiteUiModel(playbook, contentCatalog), layouts)
return createPageComposerInternal(buildSiteUiModel(playbook, contentCatalog), env, layouts)
}
function createPageComposerInternal (site, layouts) {
function createPageComposerInternal (site, env, layouts) {
/**

@@ -66,13 +67,13 @@ * Wraps the embeddable HTML contents of the specified file in a page layout.

// QUESTION should we pass the playbook to the uiModel?
const uiModel = buildUiModel(file, contentCatalog, navigationCatalog, site)
const uiModel = buildUiModel(file, contentCatalog, navigationCatalog, site, env)
let layout = uiModel.page.layout
if (!(layout in layouts)) {
if (layout === '404') throw new Error('404 layout not found')
const defaultLayout = uiModel.site.ui.defaultLayout
if (layout === defaultLayout) {
throw new Error(`Layout ${layout} not found in`, layouts)
if (defaultLayout === layout) {
throw new Error(`${layout} layout not found`)
} else if (!(defaultLayout in layouts)) {
throw new Error(`Neither ${layout} layout or fallback ${defaultLayout} layout found`)
}
if (!(defaultLayout in layouts)) {
throw new Error(`Neither layout ${layout} or default layout ${defaultLayout} found in`, layouts)
}
// TODO log a warning that the default template is being used; perhaps on file?

@@ -88,4 +89,6 @@ layout = defaultLayout

function buildUiModel (file, contentCatalog, navigationCatalog, site) {
function buildUiModel (file, contentCatalog, navigationCatalog, site, env) {
return {
antoraVersion: VERSION,
env,
page: buildPageUiModel(file, contentCatalog, navigationCatalog, site),

@@ -99,3 +102,3 @@ site,

function buildSiteUiModel (playbook, contentCatalog) {
const model = { antoraVersion: VERSION, title: playbook.site.title }
const model = { title: playbook.site.title }

@@ -129,2 +132,6 @@ let siteUrl = playbook.site.url

function buildPageUiModel (file, contentCatalog, navigationCatalog, site) {
const { component: componentName, version, stem } = file.src
if (!componentName && stem === '404') return { layout: stem, title: file.title }
// QUESTION should attributes be scoped to AsciiDoc, or should this work regardless of markup language? file.data?

@@ -138,5 +145,3 @@ const asciidoc = file.asciidoc || {}

const { component: componentName, version } = file.src
const url = file.pub.url
const component = contentCatalog.getComponent(componentName)

@@ -151,2 +156,3 @@ // QUESTION can we cache versions on file.rel so only computed once per page version group?

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

@@ -157,3 +163,2 @@ url,

attributes: pageAttributes,
layout: pageAttributes.layout || site.ui.defaultLayout,
component,

@@ -160,0 +165,0 @@ componentVersion: component.versions.find((candidate) => candidate.version === version),

{
"name": "@antora/page-composer",
"version": "1.0.0-beta.3",
"version": "1.0.0-rc.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,3 +18,3 @@ "license": "MPL-2.0",

"dependencies": {
"@antora/content-classifier": "1.0.0-beta.3",
"@antora/content-classifier": "1.0.0-rc.1",
"handlebars": "^4.0.11",

@@ -21,0 +21,0 @@ "require-from-string": "^2.0.1"

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