-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
272 additions
and
241 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import "../.astro/types"; | ||
// eslint-disable-next-line @typescript-eslint/triple-slash-reference | ||
/// <reference path="../.astro/types.d.ts" /> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* マークダウンファイルを標準入力のものに更新する。 | ||
* すでにフロントマターが書かれていることを前提とする。 | ||
*/ | ||
|
||
import { parseArgs } from "node:util"; | ||
import fs from "fs"; | ||
|
||
const argv = parseArgs({ | ||
options: { | ||
target: { type: "string", short: "t" }, | ||
}, | ||
}).values; | ||
const { target } = argv; | ||
|
||
console.log(`target: ${target}`); | ||
|
||
if (target == undefined) { | ||
throw new Error("targetを指定してください"); | ||
} | ||
if (!fs.existsSync(target)) { | ||
throw new Error(`ファイルが存在しません: ${target}`); | ||
} | ||
|
||
// フロントマターを取得 | ||
const frontmatter = fs | ||
.readFileSync(target, "utf-8") | ||
.match(/^---(\r?)\n(.*?)(\r?)\n---/s); | ||
if (frontmatter == null) { | ||
throw new Error("フロントマターが見つかりませんでした"); | ||
} | ||
|
||
// 入力マークダウンで置き換え | ||
const chunks = []; | ||
for await (const chunk of process.stdin) chunks.push(chunk); | ||
const input = Buffer.concat(chunks).toString("utf8"); | ||
const output = frontmatter[0] + "\n\n" + input; | ||
|
||
// ファイルに書き込み | ||
fs.writeFileSync(target, output); |
Oops, something went wrong.