@thegetty/quire-11ty
Advanced tools
Comparing version 1.0.0-rc.16 to 1.0.0-rc.17
@@ -19,2 +19,3 @@ /** | ||
copyrightLicensing: require('./copyright/licensing.js'), | ||
downloadLink: require('./download-link.js'), | ||
dublinCore: require('./head-tags/dublin-core.js'), | ||
@@ -21,0 +22,0 @@ figureCaption: require('./figure/caption'), |
const { html } = require('~lib/common-tags') | ||
const path = require('path') | ||
const checkFormat = require('../../_plugins/collections/filters/output.js') | ||
/** | ||
@@ -17,2 +19,29 @@ * Publication page header | ||
const pdfConfig = eleventyConfig.globalData.config.pdf | ||
/** | ||
* @function checkPagePDF | ||
* | ||
* @param {Object} config pdf object from Quire config | ||
* @param {Array<string>,string,undefined} outputs outputs setting from page frontmatter | ||
* @param {bool} frontmatterSetting pdf page setting from page frontmatter | ||
* | ||
* Check if the PDF link should be generated for this page | ||
*/ | ||
const checkPagePDF = (config,outputs,frontmatterSetting) => { | ||
// Is the output being created? | ||
if (!checkFormat('pdf', { data: { outputs } })) { | ||
return false | ||
} | ||
// Are the footer links set? | ||
if (config.pagePDF.accessLinks.find((al) => al.header === true) === undefined) { | ||
return false | ||
} | ||
// Return the core logic check | ||
return (config.pagePDF.output === true && frontmatterSetting !== false) || frontmatterSetting === true | ||
} | ||
return function (params) { | ||
@@ -25,3 +54,6 @@ const { | ||
subtitle, | ||
title | ||
title, | ||
outputs, | ||
page_pdf_output: pagePDFOutput, | ||
key, | ||
} = params | ||
@@ -43,3 +75,3 @@ | ||
class="${classes} hero__image" | ||
style="background-image: url('${path.join(imageDir, image)}');" | ||
style="background-image: url('${path.join(imageDir, image)}');" | ||
> | ||
@@ -58,2 +90,14 @@ </section> | ||
let downloadLink = '' | ||
if (checkPagePDF(pdfConfig,outputs,pagePDFOutput)) { | ||
const text = pdfConfig.pagePDF.accessLinks.find((al) => al.header === true).label | ||
const href = path.join(pdfConfig.outputDir, `${pdfConfig.filename}-${slugify(key)}.pdf`) | ||
downloadLink = html` | ||
<div class="quire-download" data-outputs-exclude="epub,pdf"> | ||
<a class="quire-download__link" href="${ href }" download><span>${ text }</span><svg class="quire-download__link__icon"><use xlink:href="#download-icon"></use></svg></a> | ||
</div> | ||
` | ||
} | ||
return html` | ||
@@ -67,2 +111,3 @@ <section class="${classes}"> | ||
${contributorsElement} | ||
${downloadLink} | ||
</div> | ||
@@ -69,0 +114,0 @@ </section> |
@@ -0,1 +1,2 @@ | ||
const path = require('path') | ||
const { html, oneLine } = require('~lib/common-tags') | ||
@@ -18,2 +19,3 @@ | ||
const markdownify = eleventyConfig.getFilter('markdownify') | ||
const slugify = eleventyConfig.getFilter('slugify') | ||
const pageTitle = eleventyConfig.getFilter('pageTitle') | ||
@@ -58,2 +60,3 @@ const removeHTML = eleventyConfig.getFilter('removeHTML') | ||
} | ||
const arrowIcon = `<span class="arrow" data-outputs-exclude="epub,pdf">${icon({ type: 'arrow-forward', description: '' })}</span>` | ||
@@ -64,3 +67,3 @@ | ||
presentation === 'abstract' && (abstract || summary) | ||
? `<div class="abstract-text">${ removeHTML(markdownify(abstract)) }</div>` | ||
? `<div class="abstract-text">${removeHTML(markdownify(abstract))}</div>` | ||
: '' | ||
@@ -67,0 +70,0 @@ |
@@ -46,3 +46,6 @@ /** | ||
subtitle=subtitle, | ||
title=title | ||
title=title, | ||
key=key, | ||
page_pdf_output=page_pdf_output, | ||
outputs=outputs | ||
%} | ||
@@ -55,3 +58,3 @@ <section class="section quire-page__content"> | ||
<div class="content"> | ||
{% bibliography citations %} | ||
{% bibliography citations outputs page_pdf_output %} | ||
</div> | ||
@@ -58,0 +61,0 @@ </div> |
@@ -33,5 +33,5 @@ const chalkFactory = require('~lib/chalk') | ||
return type === 'mla' | ||
? `${citation.replace(/\s+$/, '')} Accessed <span class="cite-current-date">DD Mon. YYYY</span>.` | ||
? `${citation.replace(/\s+$/, '')} <span class="cite-current-date__statement">Accessed <span class="cite-current-date">DD Mon. YYYY</span>.</span>` | ||
: citation | ||
} | ||
} |
@@ -14,3 +14,3 @@ const addComponentTag = require('./addComponentTag') | ||
module.exports = function(eleventyConfig, collections, options) { | ||
const { addShortcode } = shortcodeFactory(eleventyConfig, collections) | ||
const { addShortcode } = shortcodeFactory(eleventyConfig, collections) | ||
@@ -17,0 +17,0 @@ for (const component in components) { |
const chalkFactory = require('~lib/chalk') | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const parser = require('./parser') | ||
const { validateUserConfig } = require('./validator') | ||
const path = require('path') | ||
const logger = chalkFactory('[plugins:globalData]') | ||
@@ -39,19 +41,2 @@ | ||
/** | ||
* @todo replace with ajv schema validation | ||
*/ | ||
const validatePublication = (publication) => { | ||
try { | ||
const { url } = publication | ||
publication.url = url.endsWith('/') ? url : url + '/' | ||
publication.pathname = new URL(publication.url).pathname | ||
} catch (errorMessage) { | ||
logger.error( | ||
`Publication.yaml url property must be a valid url. Current url value: "${url}"` | ||
) | ||
throw new Error(errorMessage) | ||
} | ||
return publication | ||
} | ||
/** | ||
* Eleventy plugin to programmatically load global data from files | ||
@@ -78,10 +63,17 @@ * so that it is available to plugins and shortcode components. | ||
const { name: key } = path.parse(file) | ||
let value = parse(path.join(dir, file)) | ||
if (key === 'publication') { | ||
value = validatePublication(value) | ||
const parsed = parse(path.join(dir, file)) | ||
let value | ||
try { | ||
value = validateUserConfig(key, parsed) | ||
} catch (err) { | ||
logger.error(err) | ||
process.exit(1) | ||
} | ||
if (key && value) { | ||
checkForDuplicateIds(value, file) | ||
eleventyConfig.addGlobalData(key, value) | ||
if (!key || !value) { | ||
continue | ||
} | ||
checkForDuplicateIds(value, file) | ||
eleventyConfig.addGlobalData(key, value) | ||
} | ||
@@ -88,0 +80,0 @@ |
@@ -103,3 +103,3 @@ const MarkdownIt = require('markdown-it') | ||
return '<sup class="footnote-ref"><a href="#fn' + id + '" id="fnref' + refid + '" class="footnote-ref-anchor">' + caption + '</a></sup>'; | ||
return '<sup class="footnote-ref"><a href="#fn' + id + '" id="fnref' + refid + '" class="footnote-ref-anchor">' + caption + '</a></sup>' | ||
} | ||
@@ -106,0 +106,0 @@ |
@@ -1,3 +0,5 @@ | ||
const { html } = require('~lib/common-tags') | ||
const { html, oneLine } = require('~lib/common-tags') | ||
const chalkFactory = require('~lib/chalk') | ||
const checkFormat = require('../collections/filters/output.js') | ||
const path = require('path') | ||
@@ -7,2 +9,27 @@ const logger = chalkFactory('configuration:bibliography') | ||
/** | ||
* @function checkPagePDF | ||
* | ||
* @param {Object} config pdf object from Quire config | ||
* @param {Array<string>,string,undefined} outputs outputs setting from page frontmatter | ||
* @param {bool} frontmatterSetting pdf page setting from page frontmatter | ||
* | ||
* Check if the PDF link should be generated for this page | ||
*/ | ||
const checkPagePDF = (config, outputs, frontmatterSetting) => { | ||
// Is the output being created? | ||
if (!checkFormat('pdf', { data: { outputs } })) { | ||
return false | ||
} | ||
// Are the footer links set? | ||
if (config.pagePDF.accessLinks.find((al) => al.footer === true) === undefined ) { | ||
return false | ||
} | ||
// Return the core logic check | ||
return (config.pagePDF.output === true && frontmatterSetting !== false) || frontmatterSetting === true | ||
} | ||
/** | ||
* Renders a bibliography of references from page citations. | ||
@@ -20,4 +47,6 @@ * | ||
: [] | ||
const { pdf: pdfConfig } = eleventyConfig.globalData.config | ||
const { outputs, page_pdf_output: pagePDFOutput } = page.data | ||
const { displayOnPage, displayShort, heading } = page.data.config.bibliography | ||
const { displayOnPage, displayShort, heading } = page.data.config.bibliography | ||
/** | ||
@@ -34,3 +63,4 @@ * bibliography shortcode | ||
*/ | ||
return function (referenceIds = []) { | ||
return function (referenceIds = [],outputs,pagePDFOutput) { | ||
if (!page.citations && !referenceIds) return | ||
@@ -62,6 +92,4 @@ | ||
const bibliographyHeading = () => heading ? `<h2>${heading}</h2>` : '' | ||
const bibliographyItems = sortReferences(Object.values(page.citations)) | ||
const bibliographyHeading = () => heading ? `<h2>${heading}</h2>` : '' | ||
const definitionList = () => html` | ||
@@ -84,14 +112,33 @@ <dl> | ||
const downloadLink = () => { | ||
if (!checkPagePDF(pdfConfig, outputs, pagePDFOutput) || page.data.layout === 'cover') { | ||
return '' | ||
} | ||
const text = pdfConfig.pagePDF.accessLinks.find((al) => al.footer === true).label | ||
const href = path.join(pdfConfig.outputDir, `${pdfConfig.filename}-${slugify(page.data.key)}.pdf`) | ||
return oneLine`<div class="quire-download quire-download-footer-link" data-outputs-exclude="epub,pdf"> | ||
<a class="quire-download__link" href="${href}" download><span>${text}</span><svg class="quire-download__link__icon"><use xlink:href="#download-icon"></use></svg></a> | ||
</div>` | ||
} | ||
/** | ||
* Do not render the list when there are no citations nor page references | ||
* Render: the list if there are citations or page references, d/l link, or nothing | ||
*/ | ||
return bibliographyItems.length | ||
? html` | ||
switch (true) { | ||
case bibliographyItems.length > 0: | ||
return html` | ||
<div class="quire-page__content__references backmatter"> | ||
${bibliographyHeading()} | ||
${displayShort ? definitionList() : unorderedList()} | ||
${downloadLink()} | ||
</div> | ||
` | ||
: '' | ||
case downloadLink() !== '': | ||
return html`${downloadLink()}` | ||
default: | ||
return '' | ||
} | ||
} | ||
} |
@@ -39,3 +39,3 @@ const chalkFactory = require('~lib/chalk') | ||
if (!formats.includes(format)) { | ||
if (format && !formats.includes(format)) { | ||
logger.error( | ||
@@ -42,0 +42,0 @@ `Unrecognized contributors shortcode format "${format}". Supported format values are: ${formats.join(', ')}` |
const { html, oneLine } = require('~lib/common-tags') | ||
const checkFormat = require('../collections/filters/output.js') | ||
const path = require('path') | ||
/** | ||
* @function checkPagePDF | ||
* | ||
* @param {Object} config pdf object from Quire config | ||
* @param {Array<string>,string,undefined} outputs outputs setting from page frontmatter | ||
* @param {bool} frontmatterSetting pdf page setting from page frontmatter | ||
* | ||
* Check if the PDF link should be generated for this page | ||
*/ | ||
const checkPagePDF = (config, outputs, frontmatterSetting) => { | ||
// Is the output being created? | ||
if (!checkFormat('pdf', { data: { outputs } })) { | ||
return false | ||
} | ||
// Are the header links set? | ||
if (config.pagePDF.accessLinks.find((al) => al.header === true) === undefined) { | ||
return false | ||
} | ||
// Return the core logic check | ||
return (config.pagePDF.output === true && frontmatterSetting !== false) || frontmatterSetting === true | ||
} | ||
/** | ||
* A shortcode for tombstone display of object data on an entry page | ||
*/ | ||
module.exports = function(eleventyConfig, { page }) { | ||
const slugify = eleventyConfig.getFilter('slugify') | ||
const { config, objects } = eleventyConfig.globalData | ||
const { objectLinkText } = config.entryPage | ||
const { pdf: pdfConfig } = config | ||
return function (pageObjects = []) { | ||
return function (pageObjects = [], key, outputs, pagePDFOutput) { | ||
const titleCase = eleventyConfig.getFilter('titleCase') | ||
@@ -35,2 +64,12 @@ const icon = eleventyConfig.getFilter('icon') | ||
let downloadLink = '' | ||
if ( checkPagePDF(pdfConfig,outputs,pagePDFOutput) ) { | ||
const text = pdfConfig.pagePDF.accessLinks.find( al => al.header === true ).label | ||
const href = path.join( pdfConfig.outputDir, `${pdfConfig.filename}-${slugify(key)}.pdf` ) | ||
downloadLink = oneLine` | ||
<a class="button" href="${href}" target="_blank" data-outputs-exclude="epub,pdf" download><span>${text}</span><svg class="quire-download__link__icon"><use xlink:href="#download-icon"></use></svg></a> | ||
` | ||
} | ||
const table = (object) => html` | ||
@@ -44,3 +83,3 @@ <section class="quire-entry__tombstone"> | ||
</table> | ||
${objectLink(object)} | ||
${objectLink(object)}${downloadLink} | ||
</div> | ||
@@ -47,0 +86,0 @@ </section> |
@@ -0,6 +1,9 @@ | ||
const chalkFactory = require('~lib/chalk') | ||
const filterOutputs = require('../filter.js') | ||
const jsdom = require('jsdom') | ||
const filterOutputs = require('../filter.js') | ||
const truncate = require('~lib/truncate') | ||
const writer = require('./write') | ||
const logger = chalkFactory('pdf:transform') | ||
const { JSDOM } = jsdom | ||
@@ -15,5 +18,10 @@ | ||
*/ | ||
module.exports = function(eleventyConfig, collections, content) { | ||
module.exports = async function(eleventyConfig, collections, content) { | ||
const pageTitle = eleventyConfig.getFilter('pageTitle') | ||
const slugify = eleventyConfig.getFilter('slugify') | ||
const citation = eleventyConfig.getFilter('citation') | ||
const citePage = eleventyConfig.getFilter('citePage') | ||
const formatCitation = eleventyConfig.getFilter('formatCitation') | ||
const { pdf: pdfConfig } = eleventyConfig.globalData.config | ||
const slugifyIds = eleventyConfig.getFilter('slugifyIds') | ||
@@ -38,6 +46,10 @@ const writeOutput = writer(eleventyConfig) | ||
* @param {HTMLElement} element HTML element on which to set data attributes | ||
* @param {boolean} generatePagedPDF Whether to generate a PDF for this webpage | ||
* | ||
* | ||
*/ | ||
const setDataAttributes = (page, element) => { | ||
const setDataAttributes = (page, element, generatePagedPDF) => { | ||
const { dataset } = element | ||
const { parentPage } = page.data | ||
const { parentPage, layout } = page.data | ||
const { pagePDF } = pdfConfig | ||
@@ -49,2 +61,13 @@ dataset.footerPageTitle = formatTitle(page.data) | ||
} | ||
if (!generatePagedPDF) { | ||
return | ||
} | ||
if (layout === 'cover') { | ||
logger.warn(`${page.data.page.inputPath} uses a \`cover\` layout, this will only appear in the full publication PDF`) | ||
return | ||
} | ||
dataset.pagePdf = true | ||
} | ||
@@ -90,5 +113,112 @@ | ||
}) | ||
// | ||
} | ||
/** | ||
* @function trimLeadingSeparator | ||
* | ||
* Trims the publication URL path from @src attribs and style background-image URLs | ||
* @param {Object} document JSDom `document` object of a section element | ||
*/ | ||
const trimLeadingSeparator = (document) => { | ||
const urlPath = eleventyConfig.globalData.publication.pathname | ||
/** | ||
* This function removes either the deploy path or just the leading slash | ||
* | ||
* @example /foo/_assets/image.jpg -> _assets/image.jpg | ||
* @example /_assets/image.jpg -> _assets/image.jpg | ||
* @example Pass any other @src attributes (incl. `http(s)://..`) | ||
* | ||
* @todo Why does background-image carry the root asset path but no pathPrefix? | ||
*/ | ||
const trimDeployPathComponentOrSlash = (srcAttr) => { | ||
switch (true) { | ||
case srcAttr.startsWith(urlPath): | ||
return srcAttr.substr(urlPath.length) | ||
case srcAttr.startsWith('/'): | ||
return srcAttr.substr(1) | ||
default: | ||
return srcAttr | ||
} | ||
} | ||
document.querySelectorAll('[src]').forEach((asset) => { | ||
const src = asset.getAttribute('src') | ||
asset.setAttribute('src', trimDeployPathComponentOrSlash(src)) | ||
}) | ||
document.querySelectorAll('[style*="background-image"]').forEach((element) => { | ||
const backgroundImageUrl = element.style.backgroundImage.match(/[(](.*)[)]/)[1] || '' | ||
element.style.backgroundImage = `url('${trimDeployPathComponentOrSlash(backgroundImageUrl)}')` | ||
}) | ||
} | ||
/** | ||
* @function normalizeCoverPageData | ||
* | ||
* @param {Object} pageData - page data object | ||
* @param {Object} pdfConfig - configuration for the pdf | ||
* | ||
* @return {Object} data formatted for the layout at _layouts/pdf-cover-pages.liquid | ||
*/ | ||
function normalizeCoverPageData(page,pdfConfig) { | ||
const { pagePDFCoverPageCitationStyle } = page.data | ||
// NB: `id` must match the @id slug scheme in `base.11ty.js` so the cover pages have the same keys | ||
const accessURL = page.data.canonicalURL | ||
const contributors = page.data.pageContributors ?? [] | ||
const copyright = page.data.publication.copyright | ||
const id = `page-${slugify(page.data.pageData.url)}` | ||
// @todo Need license *text* per example | ||
const license = page.data.publication.license.name | ||
// @todo replace date in mla citation | ||
/** | ||
* The function to do this in the app client code: | ||
function mlaDate(date) { | ||
const options = { | ||
month: 'long' | ||
} | ||
const monthNum = date.getMonth() | ||
let month | ||
if ([4, 5, 6].includes(monthNum)) { | ||
let dateString = date.toLocaleDateString('en-US', options) | ||
month = dateString.replace(/[^A-Za-z]+/, '') | ||
} else { | ||
month = (month === 8) ? 'Sept' : date.toLocaleDateString('en-US', options).slice(0, 3) | ||
month += '.' | ||
} | ||
const day = date.getDate() | ||
const year = date.getFullYear() | ||
return [day, month, year].join(' ') | ||
} | ||
* | ||
**/ | ||
// Feed the CSL processor an access date (@todo: either make this work or use the func above..) | ||
const pageCiteData = citePage({ page, context: 'page', type: 'mla' }) | ||
const mla = formatCitation( | ||
{ ...pageCiteData, accessed: '01 Oct 1999' }, | ||
{ page, context: 'page', type: 'mla' } | ||
) | ||
const pageCitations = { | ||
chicago: citation({ context: 'page', page, type: 'chicago' }), | ||
mla | ||
} | ||
const title = pageTitle({ ...page.data, label: '' }) | ||
return { | ||
accessURL, | ||
citations: pageCitations, | ||
contributors, | ||
copyright, | ||
id, | ||
license, | ||
title | ||
} | ||
} | ||
const pdfPages = collections.pdf.map(({ outputPath }) => outputPath) | ||
@@ -111,2 +241,5 @@ | ||
const hasPagePDF = (currentPage.data.page_pdf_output === true) || (pdfConfig.pagePDF.output === true && currentPage.data.page_pdf_output !== false) | ||
const hasCoverPage = (currentPage.data.page_pdf_output === true) || (pdfConfig.pagePDF.output === true && currentPage.data.page_pdf_output !== false) | ||
sectionElement.innerHTML = mainElement.innerHTML | ||
@@ -118,3 +251,3 @@ | ||
setDataAttributes(currentPage, sectionElement) | ||
setDataAttributes(currentPage, sectionElement, hasPagePDF) | ||
@@ -130,7 +263,14 @@ // set an id for anchor links to each section | ||
// remove non-pdf content | ||
filterOutputs(sectionElement, 'pdf') | ||
collections.pdf[pageIndex].svgSymbolElements = Array.from(svgSymbolElements) | ||
collections.pdf[pageIndex].sectionElement = sectionElement | ||
// Final cleanups: remove non-pdf content, remove image leading slashes, slugify it all | ||
filterOutputs(sectionElement, 'pdf') | ||
trimLeadingSeparator(sectionElement) | ||
slugifyIds(sectionElement) | ||
collections.pdf[pageIndex].svgSymbolElements = Array.from(svgSymbolElements).map( el => el.outerHTML ) | ||
collections.pdf[pageIndex].sectionElement = sectionElement.outerHTML | ||
if (hasPagePDF && hasCoverPage) { | ||
collections.pdf[pageIndex].coverPageData = normalizeCoverPageData(currentPage,pdfConfig) | ||
} | ||
/** | ||
@@ -137,0 +277,0 @@ * Once this transform has been called for each PDF page |
const chalkFactory = require('~lib/chalk') | ||
const fs = require('fs-extra') | ||
const jsdom = require('jsdom') | ||
const path = require('path') | ||
const sass = require('sass') | ||
/** | ||
@@ -14,60 +12,36 @@ * Nota bene: | ||
module.exports = (eleventyConfig) => { | ||
const slugifyIds = eleventyConfig.getFilter('slugifyIds') | ||
const { input, output } = eleventyConfig.dir | ||
const { JSDOM } = jsdom | ||
const logger = chalkFactory('transforms:pdf:writer') | ||
const layoutPath = | ||
path.join('_plugins', 'transforms', 'outputs', 'pdf', 'layout.html') | ||
const pdfTemplatePath = | ||
path.join('_layouts', 'pdf.liquid') | ||
const coversTemplatePath = | ||
path.join('_layouts', 'pdf-cover-page.liquid') | ||
const inputDir = input | ||
const outputDir = process.env.ELEVENTY_ENV === 'production' ? 'public' : output | ||
const outputPath = path.join(outputDir, 'pdf.html') | ||
fs.ensureDirSync(path.parse(outputPath).dir) | ||
const pdfOutputPath = path.join(outputDir, 'pdf.html') | ||
const coversOutputPath = path.join(outputDir, 'pdf-covers.html') | ||
fs.ensureDirSync(path.parse(pdfOutputPath).dir) | ||
/** | ||
* Write each page section in the PDF collection to a single HTML file, | ||
* as well as one instance of SVG symbol definitions | ||
* @param {Object} collection collections.pdf with `sectionElement` property | ||
* Render the PDF pages in a liquid layout that merges them into one file | ||
* Do the same for covers of the PDF pages. | ||
* | ||
* NB: layout will only add SVG symbols once | ||
* | ||
* @param {Object} collection collections.pdf with `sectionElement`,`svgElements`, and `coverPageData` | ||
*/ | ||
return async (collection) => { | ||
const dom = await JSDOM.fromFile(layoutPath) | ||
const { document } = dom.window | ||
collection.forEach(({ outputPath, sectionElement, svgSymbolElements }, index) => { | ||
try { | ||
// only write SVG symbol definitions one time | ||
if (index === 0) { | ||
svgSymbolElements.forEach((svgSymbolElement) => { | ||
document.body.appendChild(svgSymbolElement) | ||
}) | ||
} | ||
document.body.appendChild(sectionElement) | ||
} catch (error) { | ||
logger.error(`Eleventy transform for PDF error appending content for ${outputPath} to combined output. ${error}`) | ||
} | ||
}) | ||
const publicationHtml = await eleventyConfig.javascriptFunctions.renderFile(pdfTemplatePath,{pages: collection},'liquid') | ||
const trimLeadingSlash = (string) => string.startsWith('/') ? string.substr(1) : string | ||
const coversMarkups = collection.filter( collex => collex.coverPageData ).map( (collex) => collex.coverPageData ) | ||
const coversHtml = await eleventyConfig.javascriptFunctions.renderFile(coversTemplatePath,{covers: coversMarkups},'liquid') | ||
/** | ||
* Rewrite image src attributes to be relative | ||
*/ | ||
document.querySelectorAll('[src]').forEach((asset) => { | ||
const src = asset.getAttribute('src') | ||
asset.setAttribute('src', trimLeadingSlash(src)) | ||
}) | ||
document.querySelectorAll('[style*="background-image"]').forEach((element) => { | ||
const backgroundImageUrl = element.style.backgroundImage.match(/[\(](.*)[\)]/)[1] || '' | ||
element.style.backgroundImage = `url('${trimLeadingSlash(backgroundImageUrl)}')` | ||
}) | ||
slugifyIds(document) | ||
const content = dom.serialize() | ||
try { | ||
fs.writeFileSync(outputPath, content) | ||
fs.writeFileSync(pdfOutputPath, publicationHtml) | ||
} catch (error) { | ||
@@ -77,2 +51,11 @@ logger.error(`Eleventy transform for PDF error writing combined HTML output for PDF. ${error}`) | ||
if (coversMarkups.length > 0) { | ||
try { | ||
fs.writeFileSync(coversOutputPath, coversHtml) | ||
} catch (error) { | ||
logger.error(`Eleventy transform for PDF error writing covers HTML output for PDF. ${error}`) | ||
} | ||
} | ||
const sassOptions = { | ||
@@ -79,0 +62,0 @@ loadPaths: [ |
@@ -8,15 +8,23 @@ # Changelog | ||
Changelog entries are classified using the following labels: | ||
- `Added`: for new features | ||
- `Bumped`: updated dependencies, only minor or higher will be listed | ||
- `Changed`: for changes in existing functionality | ||
- `Deprecated`: for once-stable features removed in upcoming releases | ||
- `Fixed`: for any bug fixes | ||
- `Removed`: for deprecated features removed in this release | ||
## [1.0.0-rc.17] | ||
### Added | ||
- PDF creation for a single quire webpage and cover pages | ||
- PDF transform to template using `_layouts/pdf.liquid` (was: HTML string append) | ||
- Front-end markup for PDF download link | ||
### Bumped | ||
- sharp@0.32` which includes prebuilt binaries that contain patches for macOS 10.13+ support. | ||
## [1.0.0-rc.16] | ||
## [1.0.0-rc.15] | ||
@@ -23,0 +31,0 @@ |
@@ -11,3 +11,3 @@ //@ts-check | ||
// Stylesheets | ||
import '../../fonts/index.scss'; | ||
import '../../fonts/index.scss' | ||
import '../../styles/application.scss' | ||
@@ -14,0 +14,0 @@ import '../../styles/screen.scss' |
@@ -30,2 +30,3 @@ const chalkFactory = require('~lib/chalk') | ||
order: data.order, | ||
page_pdf_output: data.page_pdf_output, | ||
short_title: data.short_title, | ||
@@ -32,0 +33,0 @@ subtitle: data.subtitle, |
{ | ||
"name": "@thegetty/quire-11ty", | ||
"version": "1.0.0-rc.16", | ||
"version": "1.0.0-rc.17", | ||
"description": "Quire 11ty static site generator", | ||
@@ -97,3 +97,3 @@ "keywords": [ | ||
"sass": "^1.54.5", | ||
"sharp": "^0.31.3", | ||
"sharp": "^0.32.6", | ||
"simple-cite": "^0.2.1", | ||
@@ -100,0 +100,0 @@ "toml": "^3.0.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
27546
1001751
275
33