diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro new file mode 100644 index 0000000..6b0be80 --- /dev/null +++ b/src/pages/blog/index.astro @@ -0,0 +1,42 @@ +--- +import { getCollection } from 'astro:content'; + +import Layout from "../../layout/Layout.astro"; +import Link from '../../components/Link.astro'; +import GoBackButton from '../../components/GoBackButton.astro'; + +const posts = await getCollection('blog', ({ data }) => !data.draft); +const postsSorted = posts.sort((a, b) => + Math.floor(b.data.pubDate / 1000) - + Math.floor(a.data.pubDate / 1000) +); + +--- + + + +
+
+

Archives

+
+
    + {postsSorted.slice(0, 4).map(post => ( +
  • + + {post.data.pubDate.toISOString().split('T')[0]} + {' '} + {post.data.title} + +
  • + ))} +
+
+
+ + \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index 6ea53b7..31b1a72 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -5,11 +5,7 @@ import Layout from "../layout/Layout.astro"; import Link from "../components/Link.astro"; import { GITHUB_REPO_URL, TWITTER_URL, GITHUB_PROFILE_URL } from '../config'; -const [posts, lists] = await Promise.all([ - getCollection('blog', ({ data }) => !data.draft), - getCollection('lists', ({ data }) => !data.draft), -]); - +const posts = await getCollection('blog', ({ data }) => !data.draft); const postsSorted = posts.sort((a, b) => Math.floor(b.data.pubDate / 1000) - Math.floor(a.data.pubDate / 1000) @@ -38,7 +34,7 @@ const year = new Date().getFullYear() - 2002;

Archive