Add document footer

This commit is contained in:
Daniel Kluge 2023-12-17 10:56:07 +01:00
parent c703096fca
commit 38492baf96
4 changed files with 30 additions and 31 deletions

View File

@ -3,9 +3,12 @@ import Layout from "./Layout.astro";
interface Props { interface Props {
title: string; title: string;
published?: Date;
srcPath?: string;
} }
const { title } = Astro.props; const { title, srcPath, published } = Astro.props;
const gitUrl = `https://git.c0ntroller.de/c0ntroller/frontpage/src/branch/astro/src/content/${srcPath}`
--- ---
<Layout title={title} showAfterMain={Astro.slots.has("footer-nav")}> <Layout title={title} showAfterMain={Astro.slots.has("footer-nav")}>
@ -13,6 +16,15 @@ const { title } = Astro.props;
<slot name="main-nav" /> : <slot name="main-nav" /> :
null} null}
<slot /> <slot />
{ published || srcPath ? <>
<hr />
<div class="contentFooter">
{ published ? <>Published on: <time datetime={published.toISOString()}>{published.toLocaleDateString("en-GB", {day: "2-digit", month: "long", year: "numeric", hour: "2-digit", minute: "2-digit", timeZone: "Europe/Berlin", hour12: false})}</time></> : null }
{ published && srcPath ? <> | </> : null}
{ srcPath ? <a href={gitUrl}>Document source</a> : null }
</div>
</>: null }
{Astro.slots.has("footer-nav") ? {Astro.slots.has("footer-nav") ?
<slot name="footer-nav" slot="after-main" /> : <slot name="footer-nav" slot="after-main" /> :
null} null}
@ -20,35 +32,21 @@ const { title } = Astro.props;
<style lang="scss" is:global> <style lang="scss" is:global>
main { main {
/*h1 { .contentFooter {
color: var(--blog_color-accent); background-color: var(--blog_background-main);
font-size: 2em; clear: right;
} border-radius: 1em;
margin-top: 10px;
padding: 14px 16px;
margin-bottom: -40px;
h2 { @media screen and (max-width: 890px) {
font-size: 1.5em; & {
margin-bottom: -10px;
} }
h3 {
font-size: 1.2em;
} }
h4 {
font-size: 1.1em;
} }
h2,
h3 {
font-weight: bold;
text-decoration: underline;
}
h2,
h3,
h4,
h5,
h6 {
color: var(--blog_color-accent-dark);
}*/
h1 + p:first-of-type { h1 + p:first-of-type {
font-style: italic; font-style: italic;
font-size: 120%; font-size: 120%;

View File

@ -24,7 +24,7 @@ const diaryPages = (await getCollection(diary)).sort((a, b) => a.data.sorting -
const { Content } = await diaryMain.render(); const { Content } = await diaryMain.render();
--- ---
<MarkdownLayout title={diaryMain.data.title}> <MarkdownLayout title={diaryMain.data.title} srcPath={`diaryMainPages/${diaryMain.id}`}>
<Content /> <Content />
<h2>Pages</h2> <h2>Pages</h2>

View File

@ -22,11 +22,12 @@ export async function getStaticPaths() {
return pathsAvailable; return pathsAvailable;
} }
const { diary } = Astro.params
const { entry } = Astro.props; const { entry } = Astro.props;
const { Content } = await entry.render(); const { Content } = await entry.render();
--- ---
<MarkdownLayout title={entry.data.title}> <MarkdownLayout title={entry.data.title} srcPath={`${diary}/${entry.id}`} published={entry.data.published}>
<DiaryNavTop collectionName="rust" slot="main-nav" /> <DiaryNavTop collectionName="rust" slot="main-nav" />
<Content /> <Content />
<DiaryNavBar collectionName="rust" slot="footer-nav" /> <DiaryNavBar collectionName="rust" slot="footer-nav" />

View File

@ -20,6 +20,6 @@ const { entry } = Astro.props;
const { Content } = await entry.render(); const { Content } = await entry.render();
--- ---
<MarkdownLayout title={entry.data.title}> <MarkdownLayout title={entry.data.title} srcPath={`projects/${entry.id}`} published={entry.data.published}>
<Content /> <Content />
</MarkdownLayout> </MarkdownLayout>