Skip to content

Instantly share code, notes, and snippets.

View rdela's full-sized avatar
🐞
Various bug fixes and improvements

Ricky de Laveaga rdela

🐞
Various bug fixes and improvements
View GitHub Profile
@rdela
rdela / prettier-plugin-js-frontmatter.js
Created July 30, 2024 13:25 — forked from d3v1an7/prettier-plugin-js-frontmatter.js
Prettier plugin for formatting JS frontmatter
import prettier from 'prettier';
import babelParser from 'prettier/plugins/babel';
import htmlParser from 'prettier/plugins/html';
const frontmatterRegex = /^---js\n([\s\S]*?)\n---\n/;
function parse(text, options) {
const match = text.match(frontmatterRegex);
if (match) {
const frontmatter = match[1];
const content = text.slice(match[0].length);