Last active
July 21, 2025 04:23
-
-
Save goooooouwa/6198cc24d0d187d87bf15779c187e520 to your computer and use it in GitHub Desktop.
#jekyll #card-diary
This file contains hidden or 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
| var fs = require('fs'); | |
| const contents = fs.readFileSync('CardDiary-JSON.json', 'utf8'); | |
| const obj = JSON.parse(contents); | |
| for (const d of obj.diaryExports) { | |
| const diary = JSON.parse(d.content); | |
| const date = d.createDate.substring(0, 10); | |
| const filename = `${date}-${diary.title || 'log'}`; | |
| const fileContent = `--- | |
| title: ${diary.title || `${date}-log` } | |
| layout: post | |
| date: ${date} | |
| category: log | |
| published: false | |
| --- | |
| ${diary.content}`; | |
| console.log(filename); | |
| fs.writeFileSync(`./tmp/${filename}.md`, fileContent, function(err) { | |
| if(err) { | |
| return console.log(err); | |
| } | |
| console.log("File saved!"); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment