diff --git a/bin/index.js b/bin/index.js index b7c8d64..a7b8d12 100644 --- a/bin/index.js +++ b/bin/index.js @@ -24,11 +24,16 @@ const argv = yargs .argv async function write ({ data, img }, dir, latest) { + const hasImage = img !== null + try { await fs.outputJSON(join(dir, 'info.json'), data, { spaces: '\t' }) - await fs.outputFile(join(dir, basename(data.img)), img) - await fs.outputFile(join(dir, `image${extname(data.img)}`), img) - await fs.outputFile(join(dir, 'index.html'), comicPage(data, latest)) + await fs.outputFile(join(dir, 'index.html'), comicPage(data, latest, hasImage)) + + if (hasImage) { + await fs.outputFile(join(dir, basename(data.img)), img) + await fs.outputFile(join(dir, `image${extname(data.img)}`), img) + } } catch (err) { await fs.remove(dir) throw err @@ -114,6 +119,8 @@ async function run () { } added = added.sort((a, b) => a.num - b.num) + await fs.remove(join(argv.dir, 'latest')) + await fs.copy(join(argv.dir, latest.toString()), join(argv.dir, 'latest')) await fs.copyFile(join(__dirname, '../node_modules/tachyons/css/tachyons.min.css'), join(argv.dir, 'tachyons.css')) await fs.copyFile(join(__dirname, '../node_modules/tachyons-columns/css/tachyons-columns.min.css'), join(argv.dir, 'tachyons-columns.css')) await fs.outputFile(join(argv.dir, 'index.html'), homePage(added)) diff --git a/lib/html.js b/lib/html.js index a7d8512..12097af 100644 --- a/lib/html.js +++ b/lib/html.js @@ -9,9 +9,7 @@ const classes = { btn: 'dib navy mh2 pa2 bg-light-blue hover-bg-lightest-blue br2 ba bw1 b--navy no-underline' } -const comicPage = ({ alt, title, transcript, num, img }, latest) => { - - return ` +const comicPage = ({ alt, title, transcript, num, img }, latest) => `