diff --git a/app/lib/navigation.ts b/app/lib/navigation.ts index 3add153..b3e4200 100644 --- a/app/lib/navigation.ts +++ b/app/lib/navigation.ts @@ -119,15 +119,17 @@ export const navigation: NavigationSection[] = [ }, ]; -export function findNavigationLink(namespace: string, href: string) { +export function findNavigationLink(namespace: string, href: string): NavigationLink | undefined { const currentUrl = `/${namespace}/${href}`.replace(/\/+/g, "/").replace(/\/$/, ""); - const links = navigation.flatMap((section) => section.links); - const subitems = links.flatMap((link) => link.subitems); - const allLinks = new Set([...links, ...subitems]); - const foundLink = Array.from(allLinks).find((link) => link.href === currentUrl); - - console.log({ allLinks, currentUrl }); + const foundLink = navigation + .flatMap((section) => section.links) + .find((link) => { + link.href === currentUrl || + link.subitems.some((subitem) => { + subitem.href === currentUrl; + }); + }); return foundLink; } diff --git a/app/pages/+config.ts b/app/pages/+config.ts index ac63eef..1cea509 100644 --- a/app/pages/+config.ts +++ b/app/pages/+config.ts @@ -23,7 +23,7 @@ export default { class: "flex min-h-full bg-white dark:bg-slate-900", }, - image: null, + image: "/og.webp", // prerender: true, prefetchStaticAssets: "hover", diff --git a/app/pages/certifications/+data.ts b/app/pages/certifications/+data.ts index 0761ff1..7938b33 100644 --- a/app/pages/certifications/+data.ts +++ b/app/pages/certifications/+data.ts @@ -1,6 +1,7 @@ import type { PageContext } from "vike/types"; import { snippetsService } from "@/services/SnippetsService"; +import { findNavigationLink } from "@/lib/navigation"; import { docsService } from "@/services/DocsService"; import { readingTime } from "reading-time-estimator"; import { useConfig } from "vike-react/useConfig"; @@ -15,6 +16,7 @@ export async function data(pageContext: PageContext) { const { key } = pageContext.routeParams; const doc = await docsService.getDoc("certifications", key); + const link = findNavigationLink("docs", key); if (!doc) { throw render(404); @@ -25,6 +27,7 @@ export async function data(pageContext: PageContext) { config({ title: buildTitle(doc.title), description: doc.description, + image: link?.og?.image || "/og.webp", }); docsService.transform(doc); diff --git a/app/pages/docs/+data.ts b/app/pages/docs/+data.ts index abfc020..a1726c4 100644 --- a/app/pages/docs/+data.ts +++ b/app/pages/docs/+data.ts @@ -27,7 +27,7 @@ export async function data(pageContext: PageContext) { config({ title: buildTitle(doc.title), description: doc.description, - image: link?.og?.image || "notfound", + image: link?.og?.image || "/og.webp", }); docsService.transform(doc); diff --git a/app/public/og.webp b/app/public/og.webp new file mode 100644 index 0000000..fcbf1e5 Binary files /dev/null and b/app/public/og.webp differ diff --git a/og_maker.afphoto b/og_maker.afphoto new file mode 100644 index 0000000..41b558a Binary files /dev/null and b/og_maker.afphoto differ diff --git a/og_maker.afphoto~lock~ b/og_maker.afphoto~lock~ new file mode 100644 index 0000000..3bfcaed Binary files /dev/null and b/og_maker.afphoto~lock~ differ diff --git a/og_maker.afphoto~lock~:com.dropbox.ignored b/og_maker.afphoto~lock~:com.dropbox.ignored new file mode 100644 index 0000000..f66c9cf Binary files /dev/null and b/og_maker.afphoto~lock~:com.dropbox.ignored differ