@vnphanquang/markdown
v2.0.2
Published
a markdown authoring toolkit from vnphanquang
Maintainers
Readme
@vnphanquang/markdown
A Markdown authoring toolkit for from personal projects; essentially a wrapper for svelte-md-template with a bunch of remark/rehype plugins. Read the blog post "Rethinking Markdown in Svelte" for an introduction.
Installation
pnpm add -D @vnphanquang/markdownUsage with [UnifiedJS]
import { unified } from 'unified';
import { createPreset } from '@vnphanquang/markdown/unified';
// assume content is safe:
const processor = unified().use(createPreset({ allowDangerousHtml: true }));Usage With Svelte:
Register the Vite plugin:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite/config';
import { markdownInSvelte } from '@vnphanquang/markdown/svelte/vite';
export default defineConfig({
plugins: [markdownInSvelte(), sveltekit({/* additional config */})],
});Use:
<script>
import { Markdown, markdown } from '@vnphanquang/markdown/svelte';
// Does this content have no code block?
let codeless = false;
</script>
<Markdown {codeless}>
{markdown`
# My Markdown Content
Do usual markdown business here, except don't indent.
`}
</Markdown>