Skip to content

Commit

Permalink
feat: functional practical info and faq framework
Browse files Browse the repository at this point in the history
  • Loading branch information
niccofyren committed Feb 7, 2025
1 parent e15fdfa commit bf9198f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 9 deletions.
12 changes: 12 additions & 0 deletions src/components/practical/FaqItem.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
import type { FaqSnippet } from "../../types";
type Props = FaqSnippet;
const { title, body } = Astro.props;
---

<div>
<h1 class="text-white text-4xl font-bold">{title}</h1>
<div class="prose text-white" set:html={body} />
</div>
26 changes: 26 additions & 0 deletions src/components/practical/PracticalPage.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
import type { InfoPage } from "../../types";
import FaqItem from "./FaqItem.astro";
import Intro from "../Intro.astro";
type Props = InfoPage;
const { title, pages = [], faq = [], intro, body } = Astro.props;
---

<div>
<h1 class="text-white text-4xl font-bold">{title}</h1>
{intro ? <Intro text={intro} /> : null}
<div class="prose" set:html={body} />
{
pages.map(({ url, title }) => (
<>
<a href={url} class="text-white">
{title}
</a>
<br />
</>
))
}
{faq.map((item) => <FaqItem {...item} />)}
</div>
7 changes: 2 additions & 5 deletions src/pages/practical/[...path].astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
import H1 from "../../components/H1.astro";
import Layout from "../../layouts/Layout.astro";
import Main from "../../components/Main.astro";
import { fetchInfoPageByPath } from "../../utils";
import PracticalPage from "../../components/practical/PracticalPage.astro";
const sectionPrefix = "/practical/";
Expand Down Expand Up @@ -30,9 +30,6 @@ if (!page) {

<Layout title=`The Gathering - ${page.title}`>
<Main>
<div class="prose text-white">
<H1 text={page.title} />
{page.children.map((child) => <a href={child.meta.url}>{child.title}</a>)}
</div>
<PracticalPage {...page} />
</Main>
</Layout>
23 changes: 19 additions & 4 deletions src/types/info.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
import type { MinimalApiPage } from "./utils";

export interface FaqSnippet {
title: string;
body?: string;
url: string;
}

export interface InfoPageSnippet {
title: string;
url: string;
}

export interface InfoPage extends MinimalApiPage {
meta: {
url: string;
} & MinimalApiPage["meta"];
title: string;
body?: string;
intro?: string;
pages?: InfoPageSnippet[];
faq?: FaqSnippet[];
}

export interface FaqPage extends MinimalApiPage {
meta: {
url: string;
} & MinimalApiPage["meta"];
title: string;
body?: string;
}
export interface FaqEntry extends MinimalApiPage {}

0 comments on commit bf9198f

Please sign in to comment.