chore: set ups docs with esm

This commit is contained in:
Enrico Sacchetti 2023-06-25 18:05:51 -04:00
commit aafd50282b
No known key found for this signature in database
GPG key ID: 3374B89ECA60D796
2 changed files with 14 additions and 10 deletions

View file

@ -1,15 +1,19 @@
import path from "node:path"; import path from "node:path";
import fs from "node:fs"; import fs from "node:fs";
import { fileURLToPath } from "node:url";
import { mdsvex } from "mdsvex"; import { mdsvex } from "mdsvex";
import { parse, walk } from "svelte/compiler"; import { parse, walk } from "svelte/compiler";
import slug from "remark-slug"; import slug from "remark-slug";
import visit from "unist-util-visit"; import { visit } from "unist-util-visit";
import { format } from "prettier"; import { format } from "prettier";
import pkg from "../package.json" assert { type: "json" }; import pkg from "../package.json" assert { type: "json" };
import component_api from "./src/COMPONENT_API.json" assert { type: "json" }; import component_api from "./src/COMPONENT_API.json" assert { type: "json" };
import Prism from "prismjs"; import Prism from "prismjs";
import "prism-svelte"; import "prism-svelte";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const component_api_by_name = component_api.components.reduce((a, c) => { const component_api_by_name = component_api.components.reduce((a, c) => {
return { return {
...a, ...a,
@ -142,6 +146,13 @@ function carbonify() {
const config = { const config = {
extensions: [".svelte", ".svx"], extensions: [".svelte", ".svx"],
preprocess: [ preprocess: [
mdsvex({
smartypants: false,
remarkPlugins: [plugin, slug, carbonify],
layout: {
_: path.join(__dirname, "src/layouts/ComponentLayout.svelte"),
},
}),
{ {
markup: ({ filename, content }) => { markup: ({ filename, content }) => {
if (/node_modules/.test(filename) || !filename.endsWith(".svelte")) if (/node_modules/.test(filename) || !filename.endsWith(".svelte"))
@ -154,13 +165,6 @@ const config = {
}; };
}, },
}, },
mdsvex({
smartypants: false,
remarkPlugins: [plugin, slug, carbonify],
layout: {
_: path.join(__dirname, "src/layouts/ComponentLayout.svelte"),
},
}),
{ {
markup({ content, filename }) { markup({ content, filename }) {
if (/node_modules/.test(filename)) return null; if (/node_modules/.test(filename)) return null;
@ -224,4 +228,4 @@ const config = {
], ],
}; };
export { ...config } export default config;

View file

@ -5,6 +5,6 @@ export default defineConfig({
plugins: [svelte()], plugins: [svelte()],
optimizeDeps: { optimizeDeps: {
include: ["clipboard-copy", "flatpickr/dist/plugins/rangePlugin"], include: ["clipboard-copy", "flatpickr/dist/plugins/rangePlugin"],
exclude: ["@roxi/routify"], exclude: ["@roxi/routify", "fsevents"],
}, },
}); });