Skip to content

Commit

Permalink
chore: improved reusability of layout (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyr33x committed Sep 13, 2024
1 parent c64d8a8 commit 0a5d8a7
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 29 deletions.
13 changes: 8 additions & 5 deletions apps/web/src/components/navbar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { DISCORD_INVITE_LINK } from "../constants";
import { GithubIcon, TwitterIcon, OverlayedIcon, DiscordIcon } from "./icons";
import Link from "../components/link.astro";
import { routes } from "../routes";
---

<style>
Expand Down Expand Up @@ -139,11 +140,13 @@ import Link from "../components/link.astro";
</div>
<!--spacer -->
<div class="hidden md:flex justify-center gap-4">
<Link to="/" title="Home">Home</Link>
<Link to="/about" title="About">About</Link>
<Link to="/canary" title="Canary">Canary</Link>
<Link to="/discord" title="Discord">Discord</Link>
<Link to="/blog" title="Blog">Blog</Link>
{
routes.map((route) => (
<Link to={route.path} title={route.title}>
{route.title}
</Link>
))
}
</div>
<!--spacer small screen-->
<div class="flex md:hidden"></div>
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { SITE_TITLE, SITE_DESCRIPTION } from "../constants";
import CommonHead from "../components/common-head.astro";
import Navbar from "../components/navbar.astro";
import Footer from "../components/footer.astro";
import "../styles/prose.css";
interface Props {
Expand Down Expand Up @@ -41,5 +42,6 @@ const { title, description, canonicalPath, ogImage } = Astro.props;
scroll-behavior: smooth;
}
</style>
<Footer />
</body>
</html>
2 changes: 0 additions & 2 deletions apps/web/src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import Footer from "../components/footer.astro";
import Layout from "../layouts/Layout.astro";
import Link from "../components/link.astro";
---
Expand All @@ -19,7 +18,6 @@ import Link from "../components/link.astro";
>
Return
</Link>
<Footer />
</div>
</main>
</Layout>
2 changes: 0 additions & 2 deletions apps/web/src/pages/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import type { GetStaticPaths } from "astro";
import { getCollection, type CollectionEntry } from "astro:content";
import Layout from "../layouts/Layout.astro";
import Footer from "../components/footer.astro";
export const getStaticPaths = (async () => {
const legalFiles = await getCollection("legal");
Expand Down Expand Up @@ -31,5 +30,4 @@ const { Content } = await post.render();
<main class="px-4 prose prose-invert mx-auto pt-28">
<Content />
</main>
<Footer />
</Layout>
2 changes: 0 additions & 2 deletions apps/web/src/pages/about.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Footer from "../components/footer.astro";
interface Frontmatter {
title: string;
Expand All @@ -18,5 +17,4 @@ const [about] = await Astro.glob<Frontmatter>("../content/about/index.mdx");
<div class="pt-2 pb-20"></div>
<about.Content />
</main>
<Footer />
</Layout>
3 changes: 0 additions & 3 deletions apps/web/src/pages/blog.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Footer from "../components/footer.astro";
import { getCollection, type CollectionEntry } from "astro:content";
import blogOgImage from "../assets/blog/overlayed-blog.png";
Expand Down Expand Up @@ -61,6 +60,4 @@ blogPosts.sort(
</ul>
</section>
</main>

<Footer />
</Layout>
2 changes: 0 additions & 2 deletions apps/web/src/pages/blog/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import type { GetStaticPaths } from "astro";
import { getCollection, type CollectionEntry } from "astro:content";
import Layout from "../../layouts/Layout.astro";
import Footer from "../../components/footer.astro";
export const getStaticPaths = (async () => {
const blogPosts = await getCollection("blog");
Expand Down Expand Up @@ -56,5 +55,4 @@ const { Content } = await post.render();
crossorigin="anonymous"
async></script>
</main>
<Footer />
</Layout>
2 changes: 0 additions & 2 deletions apps/web/src/pages/canary.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Footer from "../components/footer.astro";
import canaryOgImage from "../assets/blog/canary.png";
import { Download } from "../components/react/download";
Expand Down Expand Up @@ -53,5 +52,4 @@ const [canary] = await Astro.glob("../content/canary/index.mdx");
</div>
</section>
</main>
<Footer />
</Layout>
3 changes: 0 additions & 3 deletions apps/web/src/pages/discord-overlay-[slug].astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Footer from "../components/footer.astro";
import { getCollection, type CollectionEntry } from "astro:content";
export async function getStaticPaths() {
Expand All @@ -27,6 +26,4 @@ const { Content } = await post.render();
<main class="px-4 prose prose-invert mx-auto pt-28">
<Content />
</main>

<Footer />
</Layout>
3 changes: 0 additions & 3 deletions apps/web/src/pages/discord.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Footer from "../components/footer.astro";
import discordOgImage from "../assets/blog/discord.png";
import { DISCORD_INVITE_LINK } from "../constants";
---
Expand Down Expand Up @@ -84,5 +82,4 @@ import { DISCORD_INVITE_LINK } from "../constants";
</div>
</section>
</main>
<Footer />
</Layout>
2 changes: 0 additions & 2 deletions apps/web/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import Layout from "../layouts/Layout.astro";
import Card from "../components/card.astro";
import Link from "../components/link.astro";
import Footer from "../components/footer.astro";
import Hero from "../components/hero.astro";
import Contributors from "../components/contributors.astro";
import { Download } from "../components/react/download";
Expand Down Expand Up @@ -100,7 +99,6 @@ import resources from "../img/resources.png";
/>
</div>
<Contributors />
<Footer />
</div>
</main>
</Layout>
3 changes: 0 additions & 3 deletions apps/web/src/pages/quakecon2024.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Footer from "../components/footer.astro";
import quakeconOgImage from "../assets/blog/quakecon.png";
import Link from "../components/link.astro";
import Video from "../components/video.astro";
Expand Down Expand Up @@ -60,5 +58,4 @@ import Video from "../components/video.astro";
</div>
</section>
</main>
<Footer />
</Layout>
32 changes: 32 additions & 0 deletions apps/web/src/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
type Route<T> = Readonly<{
title: T;
path: T;
}>;

export const routes: ReadonlyArray<Route<string>> = [
{
title: "Home",
path: "/",
},
{
title: "About",
path: "/about",
},
// TODO: schedule for a later time
// {
// title: "Download",
// path: "/download",
// },
{
title: "Canary",
path: "/canary",
},
{
title: "Discord",
path: "/discord",
},
{
title: "Blog",
path: "/blog",
},
];

0 comments on commit 0a5d8a7

Please sign in to comment.