diff options
author | 2025-06-05 11:02:46 -0700 | |
---|---|---|
committer | 2025-06-05 11:02:46 -0700 | |
commit | 71c14b076fc3e5fa03d552e350743edd7f4138f2 (patch) | |
tree | ba267204e6d91a3d03eecdfb0931bff393b1210c | |
parent | 4c03c301955ba94625f0be0a56bc398ded4a42e2 (diff) | |
parent | 8995d9c59046bc6706dc7fa8884ef5fcd227b5df (diff) | |
download | anshulg-com-71c14b076fc3e5fa03d552e350743edd7f4138f2.tar.gz anshulg-com-71c14b076fc3e5fa03d552e350743edd7f4138f2.tar.zst anshulg-com-71c14b076fc3e5fa03d552e350743edd7f4138f2.zip |
Merge pull request #9 from ansg191/computed-header
Diffstat (limited to '')
-rw-r--r-- | src/layouts/ManPage.astro | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/layouts/ManPage.astro b/src/layouts/ManPage.astro index a341730..c6bc20a 100644 --- a/src/layouts/ManPage.astro +++ b/src/layouts/ManPage.astro @@ -5,21 +5,38 @@ import dayjs from "dayjs"; interface Props { title: string; - manual?: string; + section?: number; } -const { title, manual = "Miscellaneous Information Manual" } = Astro.props; +const { title, section = 7 } = Astro.props; const date = dayjs().format("ddd, MMMM D, YYYY"); +const manTitle = title.toUpperCase(); + +const sectionMap = { + 1: "General Commands Manual", + 2: "System Calls Manual", + 3: "Library Functions Manual", + 4: "Kernel Interfaces Manual", + 5: "File Formats Manual", + 6: "Games Manual", + 7: "Miscellaneous Information Manual", + 8: "System Manager's Manual", + 9: "Kernel Developer's Manual", +} as Record<number, string>; +if (!Object.prototype.hasOwnProperty.call(sectionMap, section)) { + throw new Error(`Invalid section number: ${section}`); +} +const manual = sectionMap[section]; --- <Layout title={title}> <header class="flex justify-between font-mono text-sm text-gray-500 dark:text-gray-400" > - <div>ANSHUL GUPTA (7)</div> + <div>{manTitle} ({section})</div> <h1>{manual}</h1> - <div>ANSHUL GUPTA (7)</div> + <div>{manTitle} ({section})</div> </header> <main class="font-mono pt-4"> <slot /> @@ -28,7 +45,7 @@ const date = dayjs().format("ddd, MMMM D, YYYY"); class="flex justify-between font-mono text-sm text-gray-500 dark:text-gray-400" > <div>{date}</div> - <div>ANSHUL GUPTA (7)</div> + <div>{manTitle} ({section})</div> </footer> </Layout> |