Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions packages/docs-v2/.source/index.ts

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions packages/docs-v2/.source/source.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// source.config.ts
import { defineConfig, defineDocs } from "fumadocs-mdx/config";

// lib/highlight-code.ts
import { LRUCache } from "lru-cache";
import { codeToHtml } from "shiki";
var highlightCache = new LRUCache({
max: 500,
ttl: 1e3 * 60 * 60
// 1 hour.
});
var transformers = [
{
code(node) {
if (node.tagName === "code") {
const raw = this.source;
node.properties["__raw__"] = raw;
if (raw.startsWith("npm install")) {
node.properties["__npm__"] = raw;
node.properties["__yarn__"] = raw.replace("npm install", "yarn add");
node.properties["__pnpm__"] = raw.replace("npm install", "pnpm add");
node.properties["__bun__"] = raw.replace("npm install", "bun add");
}
if (raw.startsWith("npx create-")) {
node.properties["__npm__"] = raw;
node.properties["__yarn__"] = raw.replace(
"npx create-",
"yarn create "
);
node.properties["__pnpm__"] = raw.replace(
"npx create-",
"pnpm create "
);
node.properties["__bun__"] = raw.replace("npx", "bunx --bun");
}
if (raw.startsWith("npm create")) {
node.properties["__npm__"] = raw;
node.properties["__yarn__"] = raw.replace("npm create", "yarn create");
node.properties["__pnpm__"] = raw.replace("npm create", "pnpm create");
node.properties["__bun__"] = raw.replace("npm create", "bun create");
}
if (raw.startsWith("npx")) {
node.properties["__npm__"] = raw;
node.properties["__yarn__"] = raw.replace("npx", "yarn");
node.properties["__pnpm__"] = raw.replace("npx", "pnpm dlx");
node.properties["__bun__"] = raw.replace("npx", "bunx --bun");
}
if (raw.startsWith("npm run")) {
node.properties["__npm__"] = raw;
node.properties["__yarn__"] = raw.replace("npm run", "yarn");
node.properties["__pnpm__"] = raw.replace("npm run", "pnpm");
node.properties["__bun__"] = raw.replace("npm run", "bun");
}
}
}
}
];

// source.config.ts
import rehypePrettyCode from "rehype-pretty-code";
var source_config_default = defineConfig({
mdxOptions: {
rehypePlugins: (plugins) => {
plugins.shift();
plugins.push([
rehypePrettyCode,
{
theme: {
dark: "github-dark",
light: "github-light-default"
},
transformers
}
]);
return plugins;
}
}
});
var docs = defineDocs({
dir: "content/docs"
});
export {
source_config_default as default,
docs
};
Loading