クイックスタート
unifast をインストールして、1 分以内に最初の Markdown ドキュメントをコンパイルします。
unifast をインストールして、1 分以内に最初の Markdown ドキュメントをコンパイルしましょう。
インストール
基本的な使い方
import { compile } from "@unifast/node";
const result = compile("# Hello, unifast!\n\nThis is **Markdown**.");
console.log(result.html);
// <h1>Hello, unifast!</h1>
// <p>This is <strong>Markdown</strong>.</p>これだけです。import が 1 つ、関数呼び出しが 1 つで HTML が出力されます。
プラグインを追加する
プラグインを使うと、追加機能でコンパイラを拡張できます。ほとんどのプラグインは @unifast/node に含まれており、組み込みパスを設定します。
import { compile, frontmatter, gfm } from "@unifast/node";
const source = `---
title: My Post
date: 2025-01-15
---
# My Post
A table:
| Feature | Status |
|---------|--------|
| GFM | Yes |
- [x] Task complete
- [ ] Task pending
`;
const result = compile(source, {
plugins: [frontmatter(), gfm()],
});
console.log(result.frontmatter);
// { title: "My Post", date: "2025-01-15" }
console.log(result.html);
// Rendered HTML with GFM table and task listシンタックスハイライトを追加する
import { compile, syntect } from "@unifast/node";
const result = compile(
'```js\nconsole.log("highlighted");\n```',
{ plugins: [syntect()] }
);
// Code block with syntax highlighting classes次のステップ
主要な概念 - コンパイルパイプラインとアーキテクチャを理解する。
シンタックスハイライト - コードブロックのハイライト設定の詳細。
compile() - compile 関数の完全な API リファレンス。