Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

markedpage

Package Overview
Dependencies
3
Maintainers
1
Versions
12
Issues
File Explorer

Advanced tools

markedpage

Markdown source provider & classification utilities

    0.0.12latest

Version published
Maintainers
1
Yearly downloads
644

Weekly downloads

Readme

Source

MarkedPage

A Markdown provider for my sveltekit static blog.

Features

  • Markdown source provide
  • Customize Classification
  • Support <!-- more --> tag, it will add excerpt into frontmatter
  • Use marked to parse markdown context.

Usage

  1. Create ./src/site.config.js to configure setting.
const 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;
  1. Create ./docs/_posts/2022-04-28-post1.md and put markdown files in it.
root |_docs |_posts |_2022-04-28-post1.md
  1. Use getPage or classifiedSet to get page context or page list in endpoints.
// 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 } } }

Example

<!-- 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' }

Keywords

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc