added env handling
This commit is contained in:
parent
349c87a205
commit
f402ab01e6
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -25,3 +25,6 @@ pnpm-debug.log*
|
||||||
|
|
||||||
modules/
|
modules/
|
||||||
modules_old/
|
modules_old/
|
||||||
|
|
||||||
|
# env
|
||||||
|
.env*
|
||||||
|
|
|
@ -31,7 +31,8 @@ async function readSubdir(subdir: string): Promise<dirData[]> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function generateTypeData(): Promise<RouteData[]> {
|
export async function generateTypeData(): Promise<RouteData[]> {
|
||||||
const mainDir = path.join(process.cwd(), "modules");
|
const mainDir = import.meta.env.SECRET_MODULES_PATH;
|
||||||
|
|
||||||
const subdirs = await fs.readdir(mainDir, {
|
const subdirs = await fs.readdir(mainDir, {
|
||||||
withFileTypes: true,
|
withFileTypes: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,10 +23,12 @@ import {
|
||||||
|
|
||||||
const remarkParseAtTypes: RemarkPlugin<[]> = () => {
|
const remarkParseAtTypes: RemarkPlugin<[]> = () => {
|
||||||
return (root: Md.Root): Md.Root => {
|
return (root: Md.Root): Md.Root => {
|
||||||
visit(
|
visit(root as Unist.Parent, (rawNode: Unist.Node) => {
|
||||||
root as Unist.Parent,
|
if (
|
||||||
(rawNode: Unist.Node) => {
|
rawNode.type === "text" ||
|
||||||
if (rawNode.type === "text" || (rawNode.type === "code" && (rawNode as Md.Code).lang === "qml")) {
|
(rawNode.type === "code" &&
|
||||||
|
(rawNode as Md.Code).lang === "qml")
|
||||||
|
) {
|
||||||
const node = rawNode as Md.Literal;
|
const node = rawNode as Md.Literal;
|
||||||
|
|
||||||
node.value = node.value.replace(
|
node.value = node.value.replace(
|
||||||
|
@ -38,25 +40,31 @@ const remarkParseAtTypes: RemarkPlugin<[]> = () => {
|
||||||
member: string | undefined;
|
member: string | undefined;
|
||||||
function: string | undefined;
|
function: string | undefined;
|
||||||
signal: string | undefined;
|
signal: string | undefined;
|
||||||
}
|
};
|
||||||
|
|
||||||
const groups = args.pop() as Capture;
|
const groups = args.pop() as Capture;
|
||||||
|
|
||||||
if (groups.module) {
|
if (groups.module) {
|
||||||
groups.module = groups.module.substring(0, groups.module.length - 1);
|
groups.module = groups.module.substring(
|
||||||
|
0,
|
||||||
|
groups.module.length - 1
|
||||||
|
);
|
||||||
const isQs = groups.module.startsWith("Quickshell");
|
const isQs = groups.module.startsWith("Quickshell");
|
||||||
groups.module = `99M${isQs ? "QS" : "QT_qml"}_${groups.module.replace(".", "_")}`;
|
groups.module = `99M${isQs ? "QS" : "QT_qml"}_${groups.module.replace(".", "_")}`;
|
||||||
} else groups.module = ""; // WARNING: rehype parser can't currently handle intra-module links
|
} else groups.module = ""; // WARNING: rehype parser can't currently handle intra-module links
|
||||||
|
|
||||||
groups.type = groups.type ? `99N${groups.type}` : "";
|
groups.type = groups.type ? `99N${groups.type}` : "";
|
||||||
groups.member = groups.member ? `99V${groups.member}` : "";
|
groups.member = groups.member
|
||||||
const type = groups.member ? `99T${groups.function ? "func" : groups.signal ? "signal" : "prop"}` : "";
|
? `99V${groups.member}`
|
||||||
|
: "";
|
||||||
|
const type = groups.member
|
||||||
|
? `99T${groups.function ? "func" : groups.signal ? "signal" : "prop"}`
|
||||||
|
: "";
|
||||||
return `TYPE${groups.module}${groups.type}${groups.member}${type}99TYPE`;
|
return `TYPE${groups.module}${groups.type}${groups.member}${type}99TYPE`;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
return root;
|
return root;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -124,9 +132,14 @@ const shikiRewriteTypelinks: ShikiTransformer = {
|
||||||
|
|
||||||
export const markdownConfig: AstroMarkdownOptions = {
|
export const markdownConfig: AstroMarkdownOptions = {
|
||||||
syntaxHighlight: false,
|
syntaxHighlight: false,
|
||||||
remarkPlugins: [remarkParseAtTypes, [remarkAlert, { legacyTitle: true }]],
|
remarkPlugins: [
|
||||||
|
remarkParseAtTypes,
|
||||||
|
[remarkAlert, { legacyTitle: true }],
|
||||||
|
],
|
||||||
rehypePlugins: [
|
rehypePlugins: [
|
||||||
[rehypeShiki, {
|
[
|
||||||
|
rehypeShiki,
|
||||||
|
{
|
||||||
themes: {
|
themes: {
|
||||||
light: "slack-ochin",
|
light: "slack-ochin",
|
||||||
dark: "slack-dark",
|
dark: "slack-dark",
|
||||||
|
@ -144,9 +157,13 @@ export const markdownConfig: AstroMarkdownOptions = {
|
||||||
defaultColor: false,
|
defaultColor: false,
|
||||||
wrap: true,
|
wrap: true,
|
||||||
transformers: [shikiRewriteTypelinks],
|
transformers: [shikiRewriteTypelinks],
|
||||||
}],
|
},
|
||||||
|
],
|
||||||
// FIXME: incompatible types between unified/Plugin and Astro/RehypePlugin
|
// FIXME: incompatible types between unified/Plugin and Astro/RehypePlugin
|
||||||
[sectionize as RehypePlugin, { idPropertyName: "id" }],
|
[
|
||||||
|
sectionize as unknown as RehypePlugin,
|
||||||
|
{ idPropertyName: "id" },
|
||||||
|
],
|
||||||
rehypeRewriteTypelinks,
|
rehypeRewriteTypelinks,
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue