Skip to content

Instantly share code, notes, and snippets.

@elazzabi
Created Dec 15, 2022
Embed
What would you like to do?
Transform your Revue newsletter issues to HTML
// 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