Skip to content

Instantly share code, notes, and snippets.

@himanoa
Created May 8, 2022 09:24
Show Gist options
  • Save himanoa/18a827bd623937f73f7476dabf46b763 to your computer and use it in GitHub Desktop.
Save himanoa/18a827bd623937f73f7476dabf46b763 to your computer and use it in GitHub Desktop.
const fs = require("fs")
const matter = require("gray-matter")
fs.readFileSync("test.md", "utf-8")
/* test.md body
---
author_association: OWNER
created_at: '2022-05-08T09:01:18Z'
html_url: https://github.com/himanoa/times-himanoa/issues/2#issuecomment-1120378582
id: 1120378582
issue_url: https://api.github.com/repos/himanoa/times-himanoa/issues/2
node_id: IC_kwDOHTMZ985Cx57W
performed_via_github_app:
reactions:
"+1": 0
"-1": 0
confused: 0
eyes: 0
heart: 0
hooray: 0
laugh: 0
rocket: 0
total_count: 0
url: https://api.github.com/repos/himanoa/times-himanoa/issues/comments/1120378582/reactions
updated_at: '2022-05-08T09:01:25Z'
url: https://api.github.com/repos/himanoa/times-himanoa/issues/comments/1120378582
user:
avatar_url: https://avatars.githubusercontent.com/u/18651963?v=4
events_url: https://api.github.com/users/himanoa/events{/privacy}
followers_url: https://api.github.com/users/himanoa/followers
following_url: https://api.github.com/users/himanoa/following{/other_user}
gists_url: https://api.github.com/users/himanoa/gists{/gist_id}
gravatar_id: ''
html_url: https://github.com/himanoa
id: 18651963
login: himanoa
node_id: MDQ6VXNlcjE4NjUxOTYz
organizations_url: https://api.github.com/users/himanoa/orgs
received_events_url: https://api.github.com/users/himanoa/received_events
repos_url: https://api.github.com/users/himanoa/repos
site_admin: false
starred_url: https://api.github.com/users/himanoa/starred{/owner}{/repo}
subscriptions_url: https://api.github.com/users/himanoa/subscriptions
type: User
url: https://api.github.com/users/himanoa
---
![image](https://user-images.githubusercontent.com/18651963/167289195-6e8b213f-c01a-4a1d-be19-9c87642a6e2b.png)
縦幅が狭くてなんか絶妙に書きにくい気がする。
Vimから書けるようにしてみようかな?
*/
console.dir(matter(fs.readFileSync("test.md", "utf-8")).content)
/* Output
'![image](https://user-images.githubusercontent.com/18651963/167289195-6e8b213f-c01a-4a1d-be19-9c87642a6e2b.png)\n' +
'縦幅が狭くてなんか絶妙に書きにくい気がする。\n' +
'Vimから書けるようにしてみようかな?\n'
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment