Create base layouts with basic blocks

This commit is contained in:
tobias 2024-05-19 06:57:49 +02:00
parent 8ef6ee2b2c
commit d4e0e1f994
7 changed files with 75 additions and 7 deletions

View File

@ -0,0 +1,9 @@
---
import { getCurrentYear } from "@/utils/date";
---
<footer>
<p class="text-lg font-semibold">
&copy; {getCurrentYear()} Example Website. All rights reserved.
</p>
</footer>

View File

@ -0,0 +1,38 @@
---
const links = [
{
label: "Home",
link: "/home"
},
{
label: "About",
link: "/about"
},
{
label: "Services",
link: "/services"
},
{
label: "Contact",
link: "/contact"
},
];
---
<header class="flex justify-between py-6">
<div>
<span class="font-extrabold">
Logo
</span>
</div>
<nav>
<ul class="flex gap-4 font-bold">
{links.map((item, index) => (
<li>
<a href={item.link}>{item.label}</a>
</li>
))}
</ul>
</nav>
</header>

View File

@ -30,7 +30,7 @@ const { title } = Astro.props;
}
</style>
</head>
<body class="mx-auto max-w-7xl bg-gray px-6 py-8 font-plex text-gray-200">
<body class="min-h-screen flex flex-col mx-auto max-w-7xl bg-gray px-6 py-8 font-plex text-gray-200">
<slot />
</body>
</html>

View File

@ -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;
---
<BaseLayout title={title}>
<Header/>
<div class="min-h-screen flex flex-col">
<main class="flex-grow">
<slot/>
</main>
<Footer/>
</div>
</BaseLayout>

View File

@ -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();
---
<Layout title="Paystro">
<ContentLayout title="Paystro">
<main class="" >
<h1 class="font-bold text-5xl">Paystro</h1>
<p class="mt-3 text-lg">
@ -42,4 +42,4 @@ const posts = await getPosts();
}
</div>
</main>
</Layout>
</CLayout>

View File

@ -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 ? (
<Layout title={`Paystro | ${post.title!}`}>
<ContentLayout title={`Paystro | ${post.title!}`}>
<div class="space-y-3 my-3">
<a href="/">BACK</a>
<h1 class="font-bold text-5xl">{post.title}</h1>
{post.content && <Content content={post.content} />}
</div>
</Layout>
</CLayout>
) : (
<div>404</div>
)

4
astro/src/utils/date.ts Normal file
View File

@ -0,0 +1,4 @@
export const getCurrentYear = (): number => {
const currentYear = new Date().getFullYear();
return currentYear;
}