2024-02-05 20:38:14 +00:00
|
|
|
import { component$, useContextProvider, Slot } from "@builder.io/qwik";
|
|
|
|
import { routeLoader$, type RequestHandler } from "@builder.io/qwik-city";
|
2024-01-31 21:18:13 +00:00
|
|
|
|
2024-02-03 12:07:50 +00:00
|
|
|
import Navbar from "../components/furniture/nav";
|
|
|
|
import Footer from "../components/furniture/footer";
|
2024-01-31 21:18:13 +00:00
|
|
|
|
2024-02-05 20:38:14 +00:00
|
|
|
import { ChecklistContext } from "../store/checklist-context";
|
|
|
|
|
|
|
|
import { type Sections } from "~/types/PSC";
|
|
|
|
import jsyaml from "js-yaml";
|
|
|
|
|
|
|
|
|
|
|
|
export const useChecklists = routeLoader$(async () => {
|
|
|
|
const url = import.meta.env.DEV ? `http://localhost:5173/personal-security-checklist.yml` : '/personal-security-checklist.yml';
|
|
|
|
return await fetch(url)
|
|
|
|
.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$(() => {
|
2024-02-05 20:38:14 +00:00
|
|
|
|
|
|
|
const checklists = useChecklists();
|
|
|
|
useContextProvider(ChecklistContext, checklists)
|
|
|
|
|
2024-01-31 21:18:13 +00:00
|
|
|
return (
|
|
|
|
<>
|
2024-02-03 12:07:50 +00:00
|
|
|
{/* <Header /> */}
|
|
|
|
<Navbar />
|
|
|
|
<main class="bg-base-100">
|
2024-01-31 21:18:13 +00:00
|
|
|
<Slot />
|
|
|
|
</main>
|
|
|
|
<Footer />
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
});
|