250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- useState
- built in object
- node.js
- bitcoin
- solidity
- typeScript
- evm
- CSS
- 삶
- graphQL
- SSR
- concept
- Interface
- error
- nextJS
- API
- hardhat
- express.js
- Redux
- CLASS
- Ethereum
- blockchain
- HTML
- web
- JavaScript
- 기준
- REACT
- Props
- middleware
- tailwindcss
Archives
- Today
- Total
ReasonJun
fs / path / gray-matter 본문
728x90
The fs module, the path module, and the gray-matter module are all popular JavaScript modules that are used for working with files and directories.
- The fs module provides a set of functions for reading, writing, and manipulating files and directories. It is a core module in the Node.js platform, so it is always available when you are working with Node.js.
- The path module provides a set of functions for working with file paths. It can be used to parse, normalize, and join file paths. It is also a core module in the Node.js platform.
- The gray-matter module is a third-party module that provides a simple way to parse front matter from Markdown files. Front matter is a section of text that is typically placed at the top of a Markdown file and contains metadata about the file. The gray-matter module can be used to extract the metadata from a Markdown file and store it in a JavaScript object.
Here is an example of how to use the fs, path, and gray-matter modules to read a Markdown file and extract the metadata from it:
const fs = require("fs");
const path = require("path");
const grayMatter = require("gray-matter");
const filePath = path.join(__dirname, "my-file.md");
const fileContents = fs.readFileSync(filePath, "utf8");
const matterResult = grayMatter(fileContents);
const metadata = matterResult.data;
console.log(metadata.title);
console.log(metadata.date);
This code will read the my-file.md file and extract the title and date metadata from it. The output of the code will be the title and date of the file.
728x90
'Frontend > Library' 카테고리의 다른 글
Date-fns : (a comprehensive set of date and time utilities) (0) | 2023.06.19 |
---|---|
remark / remark-html (0) | 2023.06.17 |
Styled Components (0) | 2023.06.13 |
Axios (0) | 2023.06.13 |
{JSON} Placeholder (0) | 2023.06.13 |
Comments