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_old/
|
||||
|
||||
# env
|
||||
.env*
|
||||
|
|
|
@ -31,7 +31,8 @@ async function readSubdir(subdir: string): Promise<dirData[]> {
|
|||
}
|
||||
|
||||
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, {
|
||||
withFileTypes: true,
|
||||
});
|
||||
|
|
|
@ -23,10 +23,12 @@ import {
|
|||
|
||||
const remarkParseAtTypes: RemarkPlugin<[]> = () => {
|
||||
return (root: Md.Root): Md.Root => {
|
||||
visit(
|
||||
root as Unist.Parent,
|
||||
(rawNode: Unist.Node) => {
|
||||
if (rawNode.type === "text" || (rawNode.type === "code" && (rawNode as Md.Code).lang === "qml")) {
|
||||
visit(root as Unist.Parent, (rawNode: Unist.Node) => {
|
||||
if (
|
||||
rawNode.type === "text" ||
|
||||
(rawNode.type === "code" &&
|
||||
(rawNode as Md.Code).lang === "qml")
|
||||
) {
|
||||
const node = rawNode as Md.Literal;
|
||||
|
||||
node.value = node.value.replace(
|
||||
|
@ -38,25 +40,31 @@ const remarkParseAtTypes: RemarkPlugin<[]> = () => {
|
|||
member: string | undefined;
|
||||
function: string | undefined;
|
||||
signal: string | undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const groups = args.pop() as Capture;
|
||||
|
||||
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");
|
||||
groups.module = `99M${isQs ? "QS" : "QT_qml"}_${groups.module.replace(".", "_")}`;
|
||||
} else groups.module = ""; // WARNING: rehype parser can't currently handle intra-module links
|
||||
|
||||
groups.type = groups.type ? `99N${groups.type}` : "";
|
||||
groups.member = groups.member ? `99V${groups.member}` : "";
|
||||
const type = groups.member ? `99T${groups.function ? "func" : groups.signal ? "signal" : "prop"}` : "";
|
||||
groups.member = groups.member
|
||||
? `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 root;
|
||||
};
|
||||
};
|
||||
|
@ -124,9 +132,14 @@ const shikiRewriteTypelinks: ShikiTransformer = {
|
|||
|
||||
export const markdownConfig: AstroMarkdownOptions = {
|
||||
syntaxHighlight: false,
|
||||
remarkPlugins: [remarkParseAtTypes, [remarkAlert, { legacyTitle: true }]],
|
||||
remarkPlugins: [
|
||||
remarkParseAtTypes,
|
||||
[remarkAlert, { legacyTitle: true }],
|
||||
],
|
||||
rehypePlugins: [
|
||||
[rehypeShiki, {
|
||||
[
|
||||
rehypeShiki,
|
||||
{
|
||||
themes: {
|
||||
light: "slack-ochin",
|
||||
dark: "slack-dark",
|
||||
|
@ -144,9 +157,13 @@ export const markdownConfig: AstroMarkdownOptions = {
|
|||
defaultColor: false,
|
||||
wrap: true,
|
||||
transformers: [shikiRewriteTypelinks],
|
||||
}],
|
||||
},
|
||||
],
|
||||
// FIXME: incompatible types between unified/Plugin and Astro/RehypePlugin
|
||||
[sectionize as RehypePlugin, { idPropertyName: "id" }],
|
||||
[
|
||||
sectionize as unknown as RehypePlugin,
|
||||
{ idPropertyName: "id" },
|
||||
],
|
||||
rehypeRewriteTypelinks,
|
||||
],
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue