Add links to content pages
Some checks failed
Deploy Astro / Build and Deploy (push) Failing after 44s

This commit is contained in:
Daniel Kluge 2023-12-17 11:15:40 +01:00
parent 38492baf96
commit 2c88ae7815
4 changed files with 60 additions and 3 deletions

View File

@ -3,6 +3,7 @@ title: Learning Rust
lastUpdated: 2022-06-14T12:21:00.755Z lastUpdated: 2022-06-14T12:21:00.755Z
description: "I documented my progress to learn the Rust programming language. It follows the Rust book with my own annotations. Everything is in German as these notes are mostly meant for me." description: "I documented my progress to learn the Rust programming language. It follows the Rust book with my own annotations. Everything is in German as these notes are mostly meant for me."
descriptionShort: "Me learning Rust (German)." descriptionShort: "Me learning Rust (German)."
relatedWebsite: https://doc.rust-lang.org/book/
--- ---
# Learning Rust # Learning Rust

View File

@ -1,13 +1,18 @@
--- ---
import Layout from "./Layout.astro"; import Layout from "./Layout.astro";
import { Icon } from "astro-icon";
interface Props { interface Props {
title: string; title: string;
published?: Date; published?: Date;
srcPath?: string; srcPath?: string;
moreLinks?: {
icon: string;
href: string;
}[];
} }
const { title, srcPath, published } = Astro.props; const { title, srcPath, published, moreLinks } = Astro.props;
const gitUrl = `https://git.c0ntroller.de/c0ntroller/frontpage/src/branch/astro/src/content/${srcPath}` const gitUrl = `https://git.c0ntroller.de/c0ntroller/frontpage/src/branch/astro/src/content/${srcPath}`
--- ---
@ -15,6 +20,12 @@ const gitUrl = `https://git.c0ntroller.de/c0ntroller/frontpage/src/branch/astro/
{Astro.slots.has("main-nav") ? {Astro.slots.has("main-nav") ?
<slot name="main-nav" /> : <slot name="main-nav" /> :
null} null}
{ moreLinks && moreLinks.length !== 0 ?
<div class="more">
{ moreLinks.map(l => <a href={l.href} referrerpolicy="no-referrer" class="nostyle" style={{ display: "inline-block", width: "2em" }}><Icon name={l.icon} /></a>) }
</div>
: null}
<slot /> <slot />
{ published || srcPath ? <> { published || srcPath ? <>
<hr /> <hr />
@ -155,4 +166,20 @@ const gitUrl = `https://git.c0ntroller.de/c0ntroller/frontpage/src/branch/astro/
} }
} }
} }
.more {
float: right;
@media screen and (max-width: 890px) {
& {
float: none;
display: block;
width: max-content;
margin-left: auto;
margin-right: auto;
}
}
}
</style> </style>

View File

@ -22,9 +22,23 @@ const collectionBasePath = `/blog/${diary}`;
const diaryPages = (await getCollection(diary)).sort((a, b) => a.data.sorting - b.data.sorting); const diaryPages = (await getCollection(diary)).sort((a, b) => a.data.sorting - b.data.sorting);
const { Content } = await diaryMain.render(); const { Content } = await diaryMain.render();
const moreLinks = [];
if (diaryMain.data.relatedWebsite) {
moreLinks.push({
href: diaryMain.data.relatedWebsite,
icon: "mdi:web",
});
}
if (diaryMain.data.repository) {
moreLinks.push({
href: diaryMain.data.repository,
icon: "bi:git",
});
}
--- ---
<MarkdownLayout title={diaryMain.data.title} srcPath={`diaryMainPages/${diaryMain.id}`}> <MarkdownLayout title={diaryMain.data.title} srcPath={`diaryMainPages/${diaryMain.id}`} moreLinks={moreLinks}>
<Content /> <Content />
<h2>Pages</h2> <h2>Pages</h2>

View File

@ -18,8 +18,23 @@ export async function getStaticPaths() {
const { entry } = Astro.props; const { entry } = Astro.props;
const { Content } = await entry.render(); const { Content } = await entry.render();
const moreLinks = [];
if (entry.data.relatedWebsite) {
moreLinks.push({
href: entry.data.relatedWebsite,
icon: "mdi:web",
});
}
if (entry.data.repository) {
moreLinks.push({
href: entry.data.repository,
icon: "bi:git",
});
}
--- ---
<MarkdownLayout title={entry.data.title} srcPath={`projects/${entry.id}`} published={entry.data.published}> <MarkdownLayout title={entry.data.title} srcPath={`projects/${entry.id}`} published={entry.data.published} moreLinks={moreLinks}>
<Content /> <Content />
</MarkdownLayout> </MarkdownLayout>