From a7c5debb5c47c460d782ea211a78e23e7d06030e Mon Sep 17 00:00:00 2001 From: Xevion Date: Mon, 27 Nov 2023 20:17:58 -0600 Subject: [PATCH] Separate default body contents into General layout, keep Base --- src/layouts/Base.astro | 78 ++++++++++++++------------------------- src/layouts/General.astro | 42 +++++++++++++++++++++ src/layouts/Post.astro | 6 +-- src/pages/index.astro | 4 +- 4 files changed, 75 insertions(+), 55 deletions(-) create mode 100644 src/layouts/General.astro diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 30b42ba..742e4ae 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -1,60 +1,39 @@ --- -import '@styles/global.scss'; -import '@styles/fonts.scss'; -import Header from '@components/Header.astro'; -import { ViewTransitions } from 'astro:transitions'; - -const repository_url = `https://github.com/${import.meta.env.PUBLIC_VERCEL_GIT_REPO_OWNER}/${import.meta.env.PUBLIC_VERCEL_GIT_REPO_SLUG}` -const build_revision = import.meta.env.PUBLIC_VERCEL_GIT_COMMIT_SHA; +import "@styles/global.scss"; +import "@styles/fonts.scss"; +import { ViewTransitions } from "astro:transitions"; interface Props { - title?: string; + title?: string; + build_revision?: string; } -const { title } = Astro.props; -const titleTag = title != undefined ? `${title} | undefined.behavio.rs` : 'undefined.behavio.rs'; +const { title: titleProp, build_revision } = Astro.props; +const title = + titleProp != undefined + ? `${titleProp} | undefined.behavio.rs` + : "undefined.behavio.rs"; --- + - - - - - - {titleTag} - - - - - - - - - - - -
- -
- -
-

- RSS - | - - #{build_revision.slice(0, 7)} - -

- - - diff --git a/src/layouts/General.astro b/src/layouts/General.astro new file mode 100644 index 0000000..7ffad89 --- /dev/null +++ b/src/layouts/General.astro @@ -0,0 +1,42 @@ +--- +import Base from "@layouts/Base.astro"; +import Header from "@components/Header.astro"; + +const repository_url = `https://github.com/${ + import.meta.env.PUBLIC_VERCEL_GIT_REPO_OWNER +}/${import.meta.env.PUBLIC_VERCEL_GIT_REPO_SLUG}`; +const build_revision = import.meta.env.PUBLIC_VERCEL_GIT_COMMIT_SHA; + +interface Props { + title?: string; +} + +const { title } = Astro.props; +--- + + +
+ +
+ +
+

+ RSS + | + + #{build_revision.slice(0, 7)} + +

+ diff --git a/src/layouts/Post.astro b/src/layouts/Post.astro index 6e3c5fe..484bf5a 100644 --- a/src/layouts/Post.astro +++ b/src/layouts/Post.astro @@ -1,5 +1,5 @@ --- -import Base from "@layouts/Base.astro"; +import General from "@layouts/General.astro"; import { type CollectionEntry } from 'astro:content'; import { format } from "date-fns"; @@ -10,7 +10,7 @@ const { post } = Astro.props; const { title, pubDate, tags } = post.data; const tagCount = tags.length; --- - +
- +
diff --git a/src/pages/index.astro b/src/pages/index.astro index 6aec324..5565c9a 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,12 +1,12 @@ --- import { getCollection } from "astro:content"; -import Base from "@layouts/Base.astro"; +import General from "@layouts/General.astro"; import Summary from "@components/Summary.astro"; const posts = await getCollection("blog"); posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime()); --- - + { posts.map((post) => (