Panduan Cepat
Instal unifast dan compile dokumen Markdown pertama Anda dalam waktu kurang dari satu menit.
Instal unifast dan compile dokumen Markdown pertama Anda dalam waktu kurang dari satu menit.
Instalasi
Penggunaan Dasar
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>Hanya itu. Satu import, satu pemanggilan fungsi, output HTML.
Menambahkan Plugin
Plugin memperluas compiler dengan fitur tambahan. Sebagian besar plugin disertakan dalam @unifast/node dan mengonfigurasi pass bawaan.
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 listMenambahkan Syntax Highlighting
import { compile, syntect } from "@unifast/node";
const result = compile(
'```js\nconsole.log("highlighted");\n```',
{ plugins: [syntect()] }
);
// Code block with syntax highlighting classesSelanjutnya
Konsep Kunci - Pahami pipeline kompilasi dan arsitekturnya.
Syntax Highlighting - Konfigurasi highlighting code block secara mendetail.
compile() - Referensi API lengkap untuk fungsi compile.