Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianGonz97 committed Mar 9, 2024
1 parent 6a5047b commit 8c76bcf
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions apps/www/src/routes/docs/+page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { error } from "@sveltejs/kit";
import { slugFromPath } from "$lib/utils.js";
import type { DocResolver } from "$lib/types/docs.js";
import type { PageLoad } from "./$types.js";

Expand All @@ -8,16 +7,16 @@ export const load: PageLoad = async () => {
// but I'll sort this out later - works for now :)
const modules = import.meta.glob(`/src/content/**/index.md`);

let match: { path?: string; resolver?: DocResolver } = {};
let resolver;

for (const [path, resolver] of Object.entries(modules)) {
if (slugFromPath(path) === "index") {
match = { path, resolver: resolver as unknown as DocResolver };
for (const [path, res] of Object.entries(modules)) {
if (path === "/src/content/index.md") {
resolver = res as DocResolver;
break;
}
}

const doc = await match?.resolver?.();
const doc = await resolver?.();

if (!doc || !doc.metadata) {
error(404);
Expand Down

0 comments on commit 8c76bcf

Please sign in to comment.