Skip to content

Commit

Permalink
chore: meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
zce committed Dec 6, 2023
1 parent e6897a2 commit 7581ebb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/loaders/matter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import yaml from 'yaml'
import { defineLoader } from '../config'

// https://github.com/vfile/vfile-matter/blob/main/lib/index.js
const matterRegex = /^---(?:\r?\n|\r)(?:([\s\S]*?)(?:\r?\n|\r))?---(?:\r?\n|\r|$)/
const MATTER_RE = /^---(?:\r?\n|\r)(?:([\s\S]*?)(?:\r?\n|\r))?---(?:\r?\n|\r|$)/

export default defineLoader({
// name: 'matter',
test: /\.(md|mdx)$/,
load: async file => {
const raw = file.toString().trim()
const match = raw.match(matterRegex)
const match = raw.match(MATTER_RE)
return {
data: match == null ? {} : yaml.parse(match[1]),
content: match == null ? raw : raw.slice(match[0].length).trim()
Expand Down

0 comments on commit 7581ebb

Please sign in to comment.