A Vite plugin that transforms Markdown files into HTML, allowing you to import and use Svelte components directly in your Markdown content. Extensible with remark and rehype plugins.
{, }) in code blocksnpm install @khotwa/jana
Add Jana to your vite.config.js or vite.config.ts:
import { defineConfig } from "vite";
import { jana } from "@khotwa/jana";
export default defineConfig({
plugins: [
jana(),
// ... other plugins
],
});
Add .md to the extensions in your svelte.config.js:
const config = {
extensions: [".svelte", ".md"],
// ... rest of your config
};
Import Markdown files directly as Svelte components:
<script>
import Post from './Post.md'
</script>
<Post />
In SvelteKit, you can use Markdown files directly as route pages:
src/routes/blog/+page.md
The Markdown file will be automatically processed and rendered as a Svelte page when accessed via the route.
You can import and use Svelte components directly inside your Markdown files:
<script>
import MyComponent from './MyComponent.svelte'
</script>
# My Blog Post
This is regular markdown content.
<MyComponent />
You can use components anywhere in your markdown!
Jana uses the unified ecosystem to process Markdown:
{, })The plugin automatically processes any file ending with .md during Vite's build process.
Jana supports adding custom remark and rehype plugins to extend functionality:
import { defineConfig } from "vite";
import { jana } from "@khotwa/jana";
import remarkGfm from "remark-gfm";
import rehypeShiki from "rehype-shiki";
export default defineConfig({
plugins: [
jana({
plugins: {
remark: [remarkGfm],
rehype: [[rehypeShiki, { theme: "github-dark" }]],
},
}),
],
});
Plugin format:
[remarkGfm][[rehypeSlug, { prefix: "heading-" }]]MIT