mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 12:05:28 +00:00
feat: add series feature to journal
This commit is contained in:
@@ -10,7 +10,7 @@ import GridLayout from '../layouts/GridLayout.astro';
|
||||
import PageTitle from '../components/PageTitle.astro';
|
||||
import Pagination from '../components/Pagination.astro';
|
||||
import Picture from '../components/Picture.astro';
|
||||
import { TextLink } from '../components';
|
||||
import { Banner, ListItem, OrderedList, TextLink } from '../components';
|
||||
|
||||
import { mapping } from '../mdx-components';
|
||||
|
||||
@@ -38,6 +38,12 @@ const {
|
||||
remarkPluginFrontmatter: { minutesRead },
|
||||
} = await entry.render();
|
||||
|
||||
const seriesEntries = await getCollection('journal', ({ data }) => {
|
||||
return data.series === entry.data.series;
|
||||
});
|
||||
|
||||
seriesEntries.sort(sortByDate).reverse();
|
||||
|
||||
const title = entry.data.title;
|
||||
const description = '…';
|
||||
---
|
||||
@@ -82,6 +88,26 @@ const description = '…';
|
||||
<div
|
||||
class="journal-post col-start-2 col-end-18 md:col-start-5 md:col-end-15 xl:col-start-6 xl:col-end-14 3xl:col-start-7 3xl:col-end-13"
|
||||
>
|
||||
{
|
||||
entry.data.series && (
|
||||
<Banner summary="Series">
|
||||
<OrderedList class="!mbe-0 !pis-7">
|
||||
{seriesEntries.map((item) => (
|
||||
<ListItem class="!text-[0.85em]">
|
||||
{entry.slug === item.slug ? (
|
||||
<>
|
||||
<i>{item.data.title}</i>
|
||||
📍
|
||||
</>
|
||||
) : (
|
||||
<TextLink href={`/${item.slug}/`}>{item.data.title}</TextLink>
|
||||
)}
|
||||
</ListItem>
|
||||
))}
|
||||
</OrderedList>
|
||||
</Banner>
|
||||
)
|
||||
}
|
||||
<Content components={mapping} />
|
||||
{
|
||||
entry.data.updated && (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
import { getCollection } from 'astro:content';
|
||||
|
||||
import { sortBySortKey } from '../utils';
|
||||
import { sortByDate } from '../utils';
|
||||
|
||||
import GridLayout from '../layouts/GridLayout.astro';
|
||||
import PageTitle from '../components/PageTitle.astro';
|
||||
@@ -11,7 +11,7 @@ import { Link } from '../components';
|
||||
import { mapping } from '../mdx-components';
|
||||
|
||||
const allJournal = await getCollection('journal');
|
||||
allJournal.sort(sortBySortKey);
|
||||
allJournal.sort(sortByDate);
|
||||
|
||||
const title = 'Journal';
|
||||
const description = '…';
|
||||
|
||||
@@ -15,6 +15,7 @@ export const journal = defineCollection({
|
||||
'design',
|
||||
'download',
|
||||
'film',
|
||||
'health',
|
||||
'productivity',
|
||||
'publication',
|
||||
'self-improvement',
|
||||
@@ -22,5 +23,6 @@ export const journal = defineCollection({
|
||||
'typography',
|
||||
])
|
||||
),
|
||||
series: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user