0.3.4 • Published 2 years ago
@toastdotdev/mdx v0.3.4
@toastdotdev/mdx
A toast package that sources, and optionally creates pages for, MDX files
Get Started
npm i @toastdotdev/mdx
Then in your toast.js
use it:
import { sourceMdx } from "@toastdotdev/mdx";
export const sourceData = async ({ setDataForSlug }) => {
await sourceMdx({
setDataForSlug,
directory: "./content",
slugPrefix: "/posts",
});
return;
};
or take a more manual approach and compile the mdx yourself
import { fetchMdxFromDisk, processMdx } from "@toastdotdev/mdx";
export const sourceData = async ({ setDataForSlug }) => {
const files = await fetchMdxFromDisk({ directory: "./content" });
Promise.all(
files.map(async ({ filename, file }) => {
const { content: compiledMdx, data } = await processMdx(file, {
filepath: filename,
});
await setDataForSlug(`/${data.exports.meta.slug}`, {
component: {
mode: "source",
value: compiledMdx,
},
data: mdxExports,
});
})
);
return;
};
0.3.0
2 years ago
0.3.2
2 years ago
0.3.1
2 years ago
0.3.4
2 years ago
0.3.3
2 years ago
0.2.4
3 years ago
0.2.3
3 years ago
0.2.1
3 years ago
0.2.2
3 years ago
0.2.0
3 years ago
0.1.5
3 years ago
0.1.4
3 years ago
0.1.3
4 years ago
0.1.0
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago
0.0.6
4 years ago
0.0.5
4 years ago
0.0.4
4 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago