Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion lib/fix_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const slugify = require('slugify')
const resolve = require('path').resolve
const dirname = require('path').dirname
const relative = require('path').relative
const fs = require('fs')

/**
* Internal: Performs in-place HTML filters (such as fixing URLs).
Expand Down Expand Up @@ -61,7 +62,31 @@ function fixReferences ($, fname, sources, files, page) {

// Ensure that it's available.
if (!sources[target]) {
throw new Error(`${base}: Unknown reference '${origUrl}'`)

// copy images to dist
if ($this[0].name == 'img') {

try {
let img = fs.readFileSync(cwd+'/'+target)

// metalsmith will write the image
files[target] = {
contents: img,
filename: target
}

// change to absolute URL
$this.attr(attr, '/'+target)

} catch (err) {
console.warn(`${base}: Unknown reference '${origUrl}'`)
}

} else {
console.warn(`${base}: Unknown reference '${origUrl}'`)
}

return;
}

// Relativize that absolute URL.
Expand Down
4 changes: 4 additions & 0 deletions lib/ms.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ function docpress (cwd, options) {
.metadata(meta)
.ignore('node_modules')
.ignore(`!**/{${meta.docs}{,/**/*},*.md}`)

if (Array.isArray(meta.ignore)) {
meta.ignore.forEach(str=>app.ignore(str))
}

if (Array.isArray(meta.ignore)) {
meta.ignore.forEach(str => app.ignore(str))
Expand Down