From d4e0e1f994fa0a76aedd1023c5e1e0e6ecdd8056 Mon Sep 17 00:00:00 2001 From: tobias Date: Sun, 19 May 2024 06:57:49 +0200 Subject: [PATCH] Create base layouts with basic blocks --- astro/src/components/Footer.astro | 9 +++++ astro/src/components/Header.astro | 38 +++++++++++++++++++ .../{Layout.astro => BaseLayout.astro} | 2 +- astro/src/layouts/ContentLayout.astro | 17 +++++++++ astro/src/pages/index.astro | 6 +-- astro/src/pages/posts/[id].astro | 6 +-- astro/src/utils/date.ts | 4 ++ 7 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 astro/src/components/Footer.astro create mode 100644 astro/src/components/Header.astro rename astro/src/layouts/{Layout.astro => BaseLayout.astro} (88%) create mode 100644 astro/src/layouts/ContentLayout.astro create mode 100644 astro/src/utils/date.ts diff --git a/astro/src/components/Footer.astro b/astro/src/components/Footer.astro new file mode 100644 index 0000000..3ae7d5b --- /dev/null +++ b/astro/src/components/Footer.astro @@ -0,0 +1,9 @@ +--- +import { getCurrentYear } from "@/utils/date"; +--- + + \ No newline at end of file diff --git a/astro/src/components/Header.astro b/astro/src/components/Header.astro new file mode 100644 index 0000000..2e8604c --- /dev/null +++ b/astro/src/components/Header.astro @@ -0,0 +1,38 @@ +--- +const links = [ + { + label: "Home", + link: "/home" + }, + { + label: "About", + link: "/about" + }, + { + label: "Services", + link: "/services" + }, + { + label: "Contact", + link: "/contact" + }, +]; +--- + + +
+
+ + Logo + +
+ +
\ No newline at end of file diff --git a/astro/src/layouts/Layout.astro b/astro/src/layouts/BaseLayout.astro similarity index 88% rename from astro/src/layouts/Layout.astro rename to astro/src/layouts/BaseLayout.astro index 07f7c74..69a0470 100644 --- a/astro/src/layouts/Layout.astro +++ b/astro/src/layouts/BaseLayout.astro @@ -30,7 +30,7 @@ const { title } = Astro.props; } - + diff --git a/astro/src/layouts/ContentLayout.astro b/astro/src/layouts/ContentLayout.astro new file mode 100644 index 0000000..fcd43d2 --- /dev/null +++ b/astro/src/layouts/ContentLayout.astro @@ -0,0 +1,17 @@ +--- +import BaseLayout from "./BaseLayout.astro"; +import Header from "@/components/Header.astro"; +import Footer from "@/components/Footer.astro"; + +const { title } = Astro.props; +--- + + +
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/astro/src/pages/index.astro b/astro/src/pages/index.astro index 73d2c50..cf2779e 100644 --- a/astro/src/pages/index.astro +++ b/astro/src/pages/index.astro @@ -1,11 +1,11 @@ --- -import Layout from "@/layouts/Layout.astro"; +import ContentLayout from "@/layouts/ContentLayout.astro"; import { getPosts } from "@/utils/payload"; const posts = await getPosts(); --- - +

Paystro

@@ -42,4 +42,4 @@ const posts = await getPosts(); }

-
+ diff --git a/astro/src/pages/posts/[id].astro b/astro/src/pages/posts/[id].astro index ff734d3..dcbc698 100644 --- a/astro/src/pages/posts/[id].astro +++ b/astro/src/pages/posts/[id].astro @@ -1,5 +1,5 @@ --- -import Layout from "@/layouts/Layout.astro"; +import ContentLayout from "@/layouts/ContentLayout.astro"; import Content from "@/components/Content.astro"; import type { Post } from "@/types"; import { getPost, getPosts } from "@/utils/payload"; @@ -18,13 +18,13 @@ const post = id && (await getPost(id)); { post ? ( - +
BACK

{post.title}

{post.content && }
-
+ ) : (
404
) diff --git a/astro/src/utils/date.ts b/astro/src/utils/date.ts new file mode 100644 index 0000000..b458885 --- /dev/null +++ b/astro/src/utils/date.ts @@ -0,0 +1,4 @@ +export const getCurrentYear = (): number => { + const currentYear = new Date().getFullYear(); + return currentYear; +}