Skip to content

Commit 25f1b1b

Browse files
committed
Add the ability to add content below the header on main pages
1 parent 0068dbf commit 25f1b1b

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/components/ReferenceDirectoryWithFilter/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export const ReferenceDirectoryWithFilter = ({
173173
return (
174174
<div>
175175
<div class="h-0 overflow-visible">
176-
<div class="content-grid-simple relative -top-[75px] h-[75px] border-b border-sidebar-type-color bg-accent-color px-5 pb-lg md:px-lg ">
176+
<div class="content-grid-simple absolute -top-0 -left-0 -right-0 h-[75px] border-b border-sidebar-type-color bg-accent-color px-5 pb-lg md:px-lg ">
177177
<div class="text-body col-span-2 flex w-full max-w-[750px] border-b border-accent-type-color text-accent-type-color">
178178
<input
179179
type="text"

src/content/pages/en/reference.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
slug: reference
3+
title: Reference
4+
---
5+
6+
7+
{/* Most pages don't need this, but the reference page has a Filter thing that
8+
sticks out 75px from the header. This is a little hack to push everything down
9+
by that much so nothing gets cut off. */}
10+
<div class="h-[75px]" />
11+
12+
Looking for p5.sound? Go to the <a href="https://archive.p5js.org/reference/#/libraries/p5.sound">p5.sound reference!</a>

src/layouts/BaseLayout.astro

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getCurrentLocale, getUiTranslator } from "@i18n/utils";
99
import { capitalize, getTopicInfo, type PageTopic } from "../pages/_utils";
1010
import "@styles/base.scss";
1111
import type { CollectionEntry } from "astro:content";
12+
import { getCollectionInLocaleWithFallbacks } from "@pages/_utils";
1213
1314
interface Props {
1415
title: string;
@@ -33,7 +34,18 @@ const {
3334
mainContentParentClass = "mx-5 md:mx-lg mt-md",
3435
homepageConfig,
3536
} = Astro.props;
37+
3638
const currentLocale = getCurrentLocale(Astro.url.pathname);
39+
40+
const slug = title.toLowerCase().split(/\s+/).join('-');
41+
const pages = await getCollectionInLocaleWithFallbacks("pages", currentLocale);
42+
const headerPage = pages.find((page) => page.slug === slug);
43+
let HeaderContent: any = undefined;
44+
if (headerPage) {
45+
const { Content } = await headerPage.render();
46+
HeaderContent = Content;
47+
}
48+
3749
const t = await getUiTranslator(currentLocale);
3850
const localizedTitle = t(title);
3951
const localizedSubtitle = subtitle
@@ -97,7 +109,14 @@ const headerTopic = topic
97109
)
98110
}
99111
</header>
100-
<main id="main-content">
112+
<main id="main-content" class="relative">
113+
{HeaderContent && (
114+
<div class="px-5 md:px-lg pt-sm pb-lg">
115+
<div class="rendered-markdown">
116+
<HeaderContent />
117+
</div>
118+
</div>
119+
)}
101120
<div class={mainContentParentClass}>
102121
<slot />
103122
</div>

0 commit comments

Comments
 (0)