Transform your Revue newsletter issues to HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place the JSON exported from revue in the same directory, and rename it to items.json | |
// Or just change the path here | |
const items = require( './items.json' ); | |
const issue_ids = new Set( items.map( t => t.issue_id ) ); | |
const fs = require( 'fs' ); | |
const issues = [ ...issue_ids ].map( id => { | |
const content = items.filter( i => i.issue_id === id ).sort( a => a.order ).map( t => { | |
switch( t.item_type ) { | |
case 'link': | |
let link_content = "<a href=" + t.url + ">" + t.description + "</a>"; | |
if( t.image ) { | |
link_content += "<img src=" + t.image + " />"; | |
} | |
return link_content; | |
default: | |
return t.description; | |
} | |
} ); | |
return { | |
issue_id: id, | |
content: content.join( "" ), | |
}; | |
} ); | |
fs.mkdirSync( './result' ); | |
issues.map( issue => { | |
fs.writeFileSync( './result/'+ issue.issue_id + '.html', issue.content ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment