Skip to content

Commit c05ef97

Browse files
committed
Remove MDFullWidthLayout
1 parent 05ab736 commit c05ef97

14 files changed

Lines changed: 50 additions & 45 deletions

File tree

src/helpers/frontmatter.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
*/
55

66
import type {SomePartial} from "@helpers/types";
7+
import {type PageMode, pageModeValues} from "@helpers/props";
78
import {isStrArray} from "@root/danger";
89

910
export interface Frontmatter {
11+
/*** Optional Layout Mode ***/
12+
13+
mode: PageMode;
14+
1015
/*** Mandatory ***/
1116

1217
title: string;
@@ -34,7 +39,8 @@ export interface Frontmatter {
3439
wip: boolean;
3540
}
3641
type FrontmatterWithOptionals = SomePartial<Frontmatter,
37-
"indexTitle"
42+
"mode"
43+
| "indexTitle"
3844
| "excludeFromMainIndex"
3945
| "excludeChildrenFromMainIndex"
4046
| "hidetoc"
@@ -60,6 +66,20 @@ export function makeFrontmatter(obj: unknown): Frontmatter {
6066
throw new Error(`${ERR_FIRST}Not an object.`);
6167
}
6268

69+
// OPTIONAL
70+
const mode = ("mode" in obj) ? obj.mode : "default";
71+
// TODO: Deduplicate these redundant checks
72+
// (I left both in to be extra-safe)
73+
switch (mode) {
74+
default:
75+
throw err2("a mode string", "mode", mode);
76+
case "default":
77+
case "fullwidth":
78+
}
79+
if (!pageModeValues.has(mode)) {
80+
throw err2("a string", "mode", mode);
81+
}
82+
6383
// MANDATORY
6484
if (!("title" in obj)) {
6585
throw err1("a string", "title");
@@ -123,6 +143,7 @@ export function makeFrontmatter(obj: unknown): Frontmatter {
123143
}
124144

125145
return {
146+
mode,
126147
title: obj.title,
127148
description: obj.description,
128149
keywords: obj.keywords,

src/helpers/props.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
import {TimezonelessDate} from "@helpers/timezoneless-date";
1111

1212
export type PageMode = "default" | "fullwidth";
13+
export const pageModeValues: ReadonlySet<PageMode> = new Set([
14+
"default",
15+
"fullwidth",
16+
]);
1317

1418
export function readDateStr(_prop: string): TimezonelessDate {
1519
const prop: unknown = _prop; // Cast and narrow for stronger validation

src/layouts/MDFullWidthLayout.astro

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/layouts/MDLayout.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
import {makeFrontmatter} from "@helpers/frontmatter";
3-
import GeneralLayout from "@layouts/GeneralLayout.astro";
3+
import Layout from "@layouts/GeneralLayout.astro";
44
import RightSidebar from "@components/layout-helpers/RightSidebar.astro";
55
66
import "@root/latex-helpers/rehype-plugin/md-imports";
@@ -17,7 +17,8 @@ const {
1717
const f = makeFrontmatter(frontmatter);
1818
---
1919

20-
<GeneralLayout
20+
<Layout
21+
mode={f.mode}
2122
title={f.title}
2223
description={f.description}
2324
keywords={f.keywords}
@@ -26,4 +27,4 @@ const f = makeFrontmatter(frontmatter);
2627
>
2728
<slot />
2829
<RightSidebar slot="right-sidebar" headings={headings} />
29-
</BaseLayout>
30+
</Layout>

src/pages/c/cheatsheets/general.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
layout: "@layouts/MDFullWidthLayout.astro"
2+
layout: "@layouts/MDLayout.astro"
3+
mode: fullwidth
34
title: General Programming Cheatsheet
45
description: A cheatsheet for common numbers we come across.
56
keywords: ["programming", "tech", "cheatsheet"]

src/pages/g/ffxiv/notes/2024-11-12-patch-7-1-pvp.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
layout: "@layouts/MDFullWidthLayout.astro"
2+
layout: "@layouts/MDLayout.astro"
3+
mode: fullwidth
34
title: "FFXIV: My notes on patch 7.1 PvP changes"
45
description: My notes as I go through Patch 7.1 PvP changes.
56
keywords: ["ffxiv", "final fantasy 14", "pvp", "7.1"]

src/pages/g/rocket-rats/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
layout: "@layouts/MDFullWidthLayout.astro"
2+
layout: "@layouts/MDLayout.astro"
3+
mode: fullwidth
34
title: Rocket Rats - Theorycrafting Notes
45
description: My notes for Rocket Rats
56
keywords: ["rocket rats"]

src/pages/g/vampire-survivors/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
layout: "@layouts/MDFullWidthLayout.astro"
2+
layout: "@layouts/MDLayout.astro"
3+
mode: fullwidth
34
title: Vampire Survivors Notes
45
description: My notes for Vampire Survivors
56
keywords: ["vampire survivors"]

src/pages/s/cheatsheets/math/calculus.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
layout: "@layouts/MDFullWidthLayout.astro"
2+
layout: "@layouts/MDLayout.astro"
3+
mode: fullwidth
34
title: Calculus Cheatsheet
45
description: My cheatsheet for calculus.
56
keywords: ["mathematics"]

src/pages/s/cheatsheets/math/discrete.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
layout: "@layouts/MDFullWidthLayout.astro"
2+
layout: "@layouts/MDLayout.astro"
3+
mode: fullwidth
34
title: Discrete Mathematics Cheatsheet
45
description: My cheatsheet for discrete mathematics, with an emphasis on material useful for computer science.
56
keywords: ["mathematics", "computer science", "programming"]

0 commit comments

Comments
 (0)