Created
January 4, 2021 12:58
-
-
Save szkrd/79dfe14c38417c58c36c1a0a88f04af3 to your computer and use it in GitHub Desktop.
convert pinboard exported bookmarks json to markdown
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
const fs = require('fs'); | |
const source = require('./pinboard_export.json'); | |
const uniq = (value, index, self) => self.indexOf(value) === index; | |
let text = ''; | |
source.forEach(bkm => { | |
text += `## ${bkm.description}\n`; | |
if (bkm.extended) text += `${bkm.extended}\n` | |
text += `${bkm.href}\n` | |
if (bkm.tags) { | |
const tags = bkm.tags.split(' ').map(t => { | |
t = t.toLowerCase(); | |
if (t === 'youtube') return 'video'; | |
if (t === 'javascript') return 'js'; | |
if (t === 'hardware') return 'hw'; | |
if (t === 'programming') return 'dev'; | |
if (t === 'utility') return 'tool'; | |
if (t === 'read') return ''; | |
return t; | |
}).filter(t => t.trim()).filter(uniq).sort(); | |
text += '[' + tags.join('] [') + ']\n'; | |
} | |
text += `_${bkm.time.substr(0, 10)}_\n\n`; | |
}); | |
fs.writeFileSync('bookmarks.md', text, 'utf8'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment