chore: format with treefmt
This commit is contained in:
parent
ed0b08f81e
commit
c6cca82e73
|
@ -1,16 +1,16 @@
|
||||||
import { defineConfig } from 'astro/config';
|
import { defineConfig } from "astro/config";
|
||||||
|
|
||||||
import rehypeSanitize from 'rehype-sanitize';
|
import rehypeSanitize from "rehype-sanitize";
|
||||||
import rehypeStringify from 'rehype-stringify';
|
import rehypeStringify from "rehype-stringify";
|
||||||
import rehypeRaw from 'rehype-raw';
|
import rehypeRaw from "rehype-raw";
|
||||||
import remarkParse from 'remark-parse';
|
import remarkParse from "remark-parse";
|
||||||
import remarkRehype from 'remark-rehype';
|
import remarkRehype from "remark-rehype";
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
markdown: {
|
markdown: {
|
||||||
remarkRehype: {
|
remarkRehype: {
|
||||||
allowDangerousHtml: true
|
allowDangerousHtml: true,
|
||||||
// This is fine because we are using rehypeSanitize to sanitize XSS.
|
// This is fine because we are using rehypeSanitize to sanitize XSS.
|
||||||
// See https://github.com/remarkjs/remark-rehype?tab=readme-ov-file#example-supporting-html-in-markdown-properly
|
// See https://github.com/remarkjs/remark-rehype?tab=readme-ov-file#example-supporting-html-in-markdown-properly
|
||||||
},
|
},
|
||||||
|
@ -20,6 +20,6 @@ export default defineConfig({
|
||||||
rehypeRaw,
|
rehypeRaw,
|
||||||
rehypeSanitize,
|
rehypeSanitize,
|
||||||
rehypeStringify,
|
rehypeStringify,
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,9 +28,12 @@
|
||||||
namespace = "auxolotl--docs-site";
|
namespace = "auxolotl--docs-site";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs-builder = channels: let
|
outputs-builder =
|
||||||
|
channels:
|
||||||
|
let
|
||||||
treefmt = inputs.treefmt-nix.lib.evalModule channels.nixpkgs ./treefmt.nix;
|
treefmt = inputs.treefmt-nix.lib.evalModule channels.nixpkgs ./treefmt.nix;
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
formatter = treefmt.config.build.wrapper;
|
formatter = treefmt.config.build.wrapper;
|
||||||
checks.formatting = treefmt.config.build.check inputs.self;
|
checks.formatting = treefmt.config.build.check inputs.self;
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,4 +13,4 @@ const { Content } = await post.render();
|
||||||
|
|
||||||
<div class="contents">
|
<div class="contents">
|
||||||
<Content />
|
<Content />
|
||||||
</div>
|
</div>s
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@ import { parse, join, sep } from "node:path";
|
||||||
|
|
||||||
export interface PageLinkData {
|
export interface PageLinkData {
|
||||||
id: string;
|
id: string;
|
||||||
data: { title: string; };
|
data: { title: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
type AllPathInformation = Map<string, CollectionEntry<"wiki"> | null>;
|
type AllPathInformation = Map<string, CollectionEntry<"wiki"> | null>;
|
||||||
|
@ -16,16 +16,22 @@ export interface Paths {
|
||||||
|
|
||||||
parentDirectory: PageLinkData | null;
|
parentDirectory: PageLinkData | null;
|
||||||
currentPage: PageLinkData;
|
currentPage: PageLinkData;
|
||||||
};
|
}
|
||||||
|
|
||||||
export function relativePagePaths(wikiEntries: PageLinkData[], currentPath: string): Paths {
|
export function relativePagePaths(
|
||||||
|
wikiEntries: PageLinkData[],
|
||||||
|
currentPath: string,
|
||||||
|
): Paths {
|
||||||
let currentPage: PageLinkData | undefined;
|
let currentPage: PageLinkData | undefined;
|
||||||
let parentDirectory: PageLinkData | undefined | null;
|
let parentDirectory: PageLinkData | undefined | null;
|
||||||
const siblingPages: Map<string, PageLinkData> = new Map();
|
const siblingPages: Map<string, PageLinkData> = new Map();
|
||||||
const childPages: Map<string, PageLinkData> = new Map();
|
const childPages: Map<string, PageLinkData> = new Map();
|
||||||
|
|
||||||
const currentPathParsed = parse(currentPath);
|
const currentPathParsed = parse(currentPath);
|
||||||
const currentPathExtensionless = join(currentPathParsed.dir, currentPathParsed.name);
|
const currentPathExtensionless = join(
|
||||||
|
currentPathParsed.dir,
|
||||||
|
currentPathParsed.name,
|
||||||
|
);
|
||||||
|
|
||||||
const childDirectoryPaths: Set<string> = new Set();
|
const childDirectoryPaths: Set<string> = new Set();
|
||||||
const siblingDirectoryPaths: Set<string> = new Set();
|
const siblingDirectoryPaths: Set<string> = new Set();
|
||||||
|
@ -35,7 +41,7 @@ export function relativePagePaths(wikiEntries: PageLinkData[], currentPath: stri
|
||||||
const pagePathExtensionless = join(pagePathParsed.dir, pagePathParsed.name);
|
const pagePathExtensionless = join(pagePathParsed.dir, pagePathParsed.name);
|
||||||
|
|
||||||
if (pagePathExtensionless === currentPathExtensionless) {
|
if (pagePathExtensionless === currentPathExtensionless) {
|
||||||
currentPage = entry
|
currentPage = entry;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,9 +57,14 @@ export function relativePagePaths(wikiEntries: PageLinkData[], currentPath: stri
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isIndirectChild = pagePathParsed.dir.startsWith(currentPathExtensionless + sep);
|
const isIndirectChild = pagePathParsed.dir.startsWith(
|
||||||
|
currentPathExtensionless + sep,
|
||||||
|
);
|
||||||
if (isIndirectChild) {
|
if (isIndirectChild) {
|
||||||
const nextPathSeparator = pagePathParsed.dir.indexOf(sep, currentPathExtensionless.length + 1);
|
const nextPathSeparator = pagePathParsed.dir.indexOf(
|
||||||
|
sep,
|
||||||
|
currentPathExtensionless.length + 1,
|
||||||
|
);
|
||||||
|
|
||||||
if (nextPathSeparator === -1) {
|
if (nextPathSeparator === -1) {
|
||||||
childDirectoryPaths.add(pagePathParsed.dir);
|
childDirectoryPaths.add(pagePathParsed.dir);
|
||||||
|
@ -64,9 +75,14 @@ export function relativePagePaths(wikiEntries: PageLinkData[], currentPath: stri
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isIndirectInCurrentDirectory = currentPathParsed.dir === "" || pagePathParsed.dir.startsWith(currentPathParsed.dir + sep);
|
const isIndirectInCurrentDirectory =
|
||||||
|
currentPathParsed.dir === "" ||
|
||||||
|
pagePathParsed.dir.startsWith(currentPathParsed.dir + sep);
|
||||||
if (isIndirectInCurrentDirectory) {
|
if (isIndirectInCurrentDirectory) {
|
||||||
const nextPathSeparator = pagePathParsed.dir.indexOf(sep, currentPathParsed.dir.length + 1);
|
const nextPathSeparator = pagePathParsed.dir.indexOf(
|
||||||
|
sep,
|
||||||
|
currentPathParsed.dir.length + 1,
|
||||||
|
);
|
||||||
|
|
||||||
if (nextPathSeparator === -1) {
|
if (nextPathSeparator === -1) {
|
||||||
siblingDirectoryPaths.add(pagePathParsed.dir);
|
siblingDirectoryPaths.add(pagePathParsed.dir);
|
||||||
|
@ -95,7 +111,7 @@ export function relativePagePaths(wikiEntries: PageLinkData[], currentPath: stri
|
||||||
const childDirectoryPathParsed = parse(childDirectoryPath);
|
const childDirectoryPathParsed = parse(childDirectoryPath);
|
||||||
childDirectories.push({
|
childDirectories.push({
|
||||||
id: childDirectoryPath,
|
id: childDirectoryPath,
|
||||||
data: { title: childDirectoryPathParsed.name }
|
data: { title: childDirectoryPathParsed.name },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,14 +127,14 @@ export function relativePagePaths(wikiEntries: PageLinkData[], currentPath: stri
|
||||||
const siblingDirectoryPathParsed = parse(siblingDirectoryPath);
|
const siblingDirectoryPathParsed = parse(siblingDirectoryPath);
|
||||||
siblingDirectories.push({
|
siblingDirectories.push({
|
||||||
id: siblingDirectoryPath,
|
id: siblingDirectoryPath,
|
||||||
data: { title: siblingDirectoryPathParsed.name }
|
data: { title: siblingDirectoryPathParsed.name },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPage === undefined) {
|
if (currentPage === undefined) {
|
||||||
currentPage = {
|
currentPage = {
|
||||||
id: currentPath,
|
id: currentPath,
|
||||||
data: { title: currentPathParsed.name }
|
data: { title: currentPathParsed.name },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +143,7 @@ export function relativePagePaths(wikiEntries: PageLinkData[], currentPath: stri
|
||||||
const parentDirectoryPathParsed = parse(currentPathParsed.dir);
|
const parentDirectoryPathParsed = parse(currentPathParsed.dir);
|
||||||
parentDirectory = {
|
parentDirectory = {
|
||||||
id: currentPathParsed.dir,
|
id: currentPathParsed.dir,
|
||||||
data: { title: parentDirectoryPathParsed.name }
|
data: { title: parentDirectoryPathParsed.name },
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
parentDirectory = null;
|
parentDirectory = null;
|
||||||
|
@ -143,11 +159,14 @@ export function relativePagePaths(wikiEntries: PageLinkData[], currentPath: stri
|
||||||
|
|
||||||
currentPage,
|
currentPage,
|
||||||
parentDirectory,
|
parentDirectory,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function allPageAndDirectoryPaths(wikiEntries: CollectionEntry<"wiki">[]): AllPathInformation {
|
export function allPageAndDirectoryPaths(
|
||||||
const pathInformation: Map<string, CollectionEntry<"wiki"> | null> = new Map();
|
wikiEntries: CollectionEntry<"wiki">[],
|
||||||
|
): AllPathInformation {
|
||||||
|
const pathInformation: Map<string, CollectionEntry<"wiki"> | null> =
|
||||||
|
new Map();
|
||||||
|
|
||||||
for (const entry of wikiEntries) {
|
for (const entry of wikiEntries) {
|
||||||
pathInformation.set(entry.id, entry);
|
pathInformation.set(entry.id, entry);
|
||||||
|
|
Loading…
Reference in a new issue