personal-security-checklist/web/src/routes/layout.tsx

39 lines
1.1 KiB
TypeScript
Raw Normal View History

import { component$, useContextProvider, Slot } from "@builder.io/qwik";
import { routeLoader$, type RequestHandler } from "@builder.io/qwik-city";
import jsyaml from "js-yaml";
import Navbar from "~/components/furniture/nav";
import Footer from "~/components/furniture/footer";
import { ChecklistContext } from "~/store/checklist-context";
import type { Sections } from "~/types/PSC";
export const useChecklists = routeLoader$(async () => {
const remoteUrl = 'https://raw.githubusercontent.com/Lissy93/personal-security-checklist/HEAD/personal-security-checklist.yml';
return fetch(remoteUrl)
.then((res) => res.text())
.then((res) => jsyaml.load(res) as Sections)
.catch(() => []);
});
2024-01-31 21:18:13 +00:00
export const onGet: RequestHandler = async ({ cacheControl }) => {
cacheControl({
staleWhileRevalidate: 60 * 60 * 24 * 7,
maxAge: 5,
});
};
export default component$(() => {
const checklists = useChecklists();
useContextProvider(ChecklistContext, checklists);
2024-01-31 21:18:13 +00:00
return (
<>
2024-02-03 12:07:50 +00:00
<Navbar />
<main class="bg-base-100 min-h-full">
2024-01-31 21:18:13 +00:00
<Slot />
</main>
<Footer />
</>
);
});