rework/lightweight #12

Merged
GauthierWebDev merged 106 commits from rework/lightweight into main 2025-04-21 16:27:38 +00:00
4 changed files with 40 additions and 16 deletions
Showing only changes of commit 4625a92206 - Show all commits

View File

@ -1,3 +1,4 @@
import type { NavigationSubItem } from "@/libs/navigation";
import type { JSX } from "solid-js"; import type { JSX } from "solid-js";
import { usePageContext } from "vike-solid/usePageContext"; import { usePageContext } from "vike-solid/usePageContext";
@ -21,7 +22,8 @@ type PageLinkProps = Omit<JSX.IntrinsicElements["div"], "dir" | "title"> & {
}; };
function PageLink(props: PageLinkProps) { function PageLink(props: PageLinkProps) {
const pageCategory = navigation.find((section) => { const getPageCategory = () =>
navigation.find((section) => {
return section.links.some( return section.links.some(
(link) => (link) =>
link.href === props.href || link.href === props.href ||
@ -43,9 +45,9 @@ function PageLink(props: PageLinkProps) {
)} )}
> >
<p class="flex flex-col gap-0"> <p class="flex flex-col gap-0">
{pageCategory && ( {getPageCategory() && (
<span class="text-violet-600 text-sm mb-1 leading-3"> <span class="text-violet-600 text-sm mb-1 leading-3">
{pageCategory.title} {getPageCategory()?.title}
</span> </span>
)} )}
<span class="leading-4">{props.title}</span> <span class="leading-4">{props.title}</span>
@ -87,13 +89,23 @@ export function PrevNextLinks() {
return [previousPage, nextPage]; return [previousPage, nextPage];
}; };
const [previousPage, nextPage] = getNeighboringLinks(); if (getNeighboringLinks().length === 0) return null;
if (!nextPage && !previousPage) return null;
return ( return (
<dl class="mt-12 flex gap-4 border-t border-slate-200 pt-6"> <dl class="mt-12 flex gap-4 border-t border-slate-200 pt-6">
{previousPage && <PageLink dir="previous" {...previousPage} />} {getNeighboringLinks()[0] && (
{nextPage && <PageLink class="ml-auto text-right" {...nextPage} />} <PageLink
dir="previous"
{...(getNeighboringLinks()[0] as NavigationSubItem)}
/>
)}
{getNeighboringLinks()[1] && (
<PageLink
class="ml-auto text-right"
{...(getNeighboringLinks()[1] as NavigationSubItem)}
/>
)}
</dl> </dl>
); );
} }

View File

@ -1,8 +1,9 @@
import type { JSXElement } from "solid-js"; import type { JSXElement } from "solid-js";
import { TableOfContents } from "@/partials/TableOfContents"; // import { TableOfContents } from "@/partials/TableOfContents";
import { PrevNextLinks } from "@/components/PrevNextLinks"; import { PrevNextLinks } from "@/components/PrevNextLinks";
import { usePageContext } from "vike-solid/usePageContext"; import { usePageContext } from "vike-solid/usePageContext";
import { clientOnly } from "vike-solid/clientOnly";
import { clock } from "solid-heroicons/outline"; import { clock } from "solid-heroicons/outline";
import { navigation } from "@/libs/navigation"; import { navigation } from "@/libs/navigation";
import { Prose } from "@/components/Prose"; import { Prose } from "@/components/Prose";
@ -12,6 +13,10 @@ type DocsLayoutProps = {
children: JSXElement; children: JSXElement;
}; };
const TableOfContents = clientOnly(
async () => (await import("@/partials/TableOfContents")).TableOfContents,
);
export function DocsLayout(props: DocsLayoutProps) { export function DocsLayout(props: DocsLayoutProps) {
const pageContext = usePageContext(); const pageContext = usePageContext();

View File

@ -1,4 +1,3 @@
import type { SectionCache } from "@/services/DocCache";
import type { PageContext } from "vike/types"; import type { PageContext } from "vike/types";
import { useConfig } from "vike-solid/useConfig"; import { useConfig } from "vike-solid/useConfig";
@ -9,6 +8,7 @@ export type Data = Awaited<ReturnType<typeof data>>;
export async function data(pageContext: PageContext) { export async function data(pageContext: PageContext) {
const config = useConfig(); const config = useConfig();
await docCache.waitingForCache(20000);
const { const {
exports: { frontmatter }, exports: { frontmatter },
@ -28,6 +28,13 @@ export async function data(pageContext: PageContext) {
const doc = docCache.get(cachePathname); const doc = docCache.get(cachePathname);
if (!doc) {
console.error(
`DocCache: No doc found for ${cachePathname}. This is a bug!`,
"Please report it to the maintainers.",
);
}
return { return {
sections: doc?.sections || [], sections: doc?.sections || [],
frontmatter, frontmatter,

View File

@ -16,7 +16,7 @@ Découvre donc de bons conseils pour t'aider à te préparer au mieux !
<QuickLinks.QuickLink <QuickLinks.QuickLink
title="DWWM" title="DWWM"
description="Titre professionnel Développeur Web et Web Mobile" description="Titre professionnel Développeur Web et Web Mobile"
href="./dwwm" href="certifications/dwwm"
icon="presets" icon="presets"
/> />
</QuickLinks> </QuickLinks>