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";
|
|
|
|
import jsyaml from "js-yaml";
|
|
|
|
|
2024-02-10 13:13:52 +00:00
|
|
|
import Navbar from "~/components/furniture/nav";
|
|
|
|
import Footer from "~/components/furniture/footer";
|
|
|
|
import { ChecklistContext } from "~/store/checklist-context";
|
|
|
|
import type { Sections } from "~/types/PSC";
|
2024-02-05 20:38:14 +00:00
|
|
|
|
|
|
|
export const useChecklists = routeLoader$(async () => {
|
2024-02-10 13:13:52 +00:00
|
|
|
const remoteUrl = 'https://gist.githubusercontent.com/Lissy93/0c26e4255b6fabc2c027ac72a4428aeb/raw/4ccdbc71e0fffdef53472cf98acbe40b0acf982b/personal-security-checklist.yml';
|
|
|
|
// TODO: Update this URL to point to the Git repository
|
|
|
|
return fetch(remoteUrl)
|
2024-02-05 20:38:14 +00:00
|
|
|
.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();
|
2024-02-10 13:13:52 +00:00
|
|
|
useContextProvider(ChecklistContext, checklists);
|
2024-02-05 20:38:14 +00:00
|
|
|
|
2024-01-31 21:18:13 +00:00
|
|
|
return (
|
|
|
|
<>
|
2024-02-03 12:07:50 +00:00
|
|
|
<Navbar />
|
2024-02-09 22:51:32 +00:00
|
|
|
<main class="bg-base-100 min-h-full">
|
2024-01-31 21:18:13 +00:00
|
|
|
<Slot />
|
|
|
|
</main>
|
|
|
|
<Footer />
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
});
|