refactor: use a content collection for talks
This commit is contained in:
parent
85644e4f2d
commit
7b97ad3af2
42 changed files with 111 additions and 92 deletions
|
|
@ -6,22 +6,21 @@ import Markdown from "~/components/Markdown.astro";
|
|||
import Slides from "~/components/talk/Slides.astro";
|
||||
import Video from "~/components/talk/Video.astro";
|
||||
import { getSlugFromFile } from "~/utils.ts";
|
||||
import { getCollection } from 'astro:content';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const talks = await Astro.glob("../../talks/*.md");
|
||||
const talks = await getCollection('talk')
|
||||
|
||||
return talks.map((talk) => {
|
||||
const slug = getSlugFromFile(talk.file);
|
||||
|
||||
return {
|
||||
params: { slug },
|
||||
params: { slug: talk.slug },
|
||||
props: { talk },
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const { Content } = Astro.props.talk;
|
||||
const { events, speakerdeck, title, video } = Astro.props.talk.frontmatter;
|
||||
const { Content } = await Astro.props.talk.render();
|
||||
const { events, speakerdeck, title, video } = Astro.props.talk.data;
|
||||
---
|
||||
|
||||
<Layout title={title}>
|
||||
|
|
|
|||
|
|
@ -1,25 +1,24 @@
|
|||
---
|
||||
import PageLayout from "~/layouts/PageLayout.astro";
|
||||
import _ from "lodash";
|
||||
import { getSlugFromFile } from "~/utils.ts";
|
||||
import ListingPage from "~/components/ListingPage.astro";
|
||||
import _ from "lodash";
|
||||
import { getCollection } from 'astro:content';
|
||||
|
||||
const talks = await Astro.glob("../../talks/*.md");
|
||||
const talks = await getCollection('talk');
|
||||
|
||||
const talkCount = _(talks)
|
||||
.flatMap((talk) => talk.frontmatter.events)
|
||||
.flatMap((talk) => talk.data.events)
|
||||
.size();
|
||||
|
||||
const sortedTalks = talks
|
||||
.map((talk) => {
|
||||
const slug = `/talks/${getSlugFromFile(talk.file)}`;
|
||||
const slug = `/talks/${talk.slug}`
|
||||
|
||||
return { slug, item: talk };
|
||||
})
|
||||
.sort((b, a) => {
|
||||
const events = [
|
||||
a.item.frontmatter.events[a.item.frontmatter.events.length - 1],
|
||||
b.item.frontmatter.events[b.item.frontmatter.events.length - 1],
|
||||
a.item.data.events[a.item.data.events.length - 1],
|
||||
b.item.data.events[b.item.data.events.length - 1],
|
||||
];
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue