markedpage
Advanced tools
Markdown source provider & classification utilities
Weekly downloads
Readme
A Markdown provider for my sveltekit static blog.
<!-- more -->
tag, it will add excerpt into frontmatterconst config = {
title: "TestWebSite",
classifier: [
{ id: 'post', params: { path: '/_posts/' }, type: 'directory' },
{ id: 'tag', params: { keys: ['tag', 'tags'] }, type: 'frontmatter' }
],
marked: {
options: {},
extensions: {}
},
};
export default config;
root
|_docs
|_posts
|_2022-04-28-post1.md
// example.ts
import type { DirectoryClassifierResult } from 'markedpage';
import { getPage, classifiedSet } from 'markedpage';
import type { RequestHandler } from '@sveltejs/kit';
export const get : RequestHandler = async () => {
// Get list.
const pageSet: DirectoryClassifierResult = await classifiedSet("post");
const pages = pageSet.pages;
// Get page.
const page = await getPage('post1');
const context = await page.render();
return {
body: {
pages: pages,
metadata: page.frontMatter,
body: context
}
}
}
<!-- 2022-04-28-firstpage.md -->
title: FirstPost
tags:
- test
This is summary field.
<!-- more -->
This is context block.
It will be passed to
{
frontMatter: {
title: 'FirstPost',
tags: [ 'test' ],
excerpt: 'This is summary field.',
created: 2022-04-28T00:00:00.000Z
},
sourcePath: 'docs/2022-04-28-firstpage.md',
indexPath: 'docs/2022-04-28-firstpage',
render: [Function: render],
slugKey: 'firstpage'
}