Skip to content

Instantly share code, notes, and snippets.

@elazzabi
Created December 15, 2022 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elazzabi/d57bae2afa38f1815ad885e7277402f4 to your computer and use it in GitHub Desktop.
Save elazzabi/d57bae2afa38f1815ad885e7277402f4 to your computer and use it in GitHub Desktop.
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