feat: add event, news, technical, and workshop pages with pagination and details
This commit is contained in:
32
src/pages/events/[...page].astro
Normal file
32
src/pages/events/[...page].astro
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
import type { GetStaticPaths } from "astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import Main from "@/layouts/Main.astro";
|
||||
import Layout from "@/layouts/Layout.astro";
|
||||
import Header from "@/components/Header.astro";
|
||||
import Footer from "@/components/Footer.astro";
|
||||
import Card from "@/components/Card.astro";
|
||||
import Pagination from "@/components/Pagination.astro";
|
||||
import getSortedPosts from "@/utils/getSortedPosts";
|
||||
import { SITE } from "@/config";
|
||||
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
const events = await getCollection("events", ({ data }) => !data.draft);
|
||||
return paginate(getSortedPosts(events), { pageSize: SITE.postPerPage });
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
const { page } = Astro.props;
|
||||
---
|
||||
|
||||
<Layout title={`Events | ${SITE.title}`}>
|
||||
<Header />
|
||||
<Main pageTitle="Events" pageDesc="All upcoming and past events organized by HEC IA.">
|
||||
<ul>
|
||||
{page.data.map(data => <Card {...data} />)}
|
||||
</ul>
|
||||
</Main>
|
||||
|
||||
<Pagination {page} />
|
||||
|
||||
<Footer noMarginTop={page.lastPage > 1} />
|
||||
</Layout>
|
||||
27
src/pages/events/[...slug]/index.astro
Normal file
27
src/pages/events/[...slug]/index.astro
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import PostDetails from "@/layouts/PostDetails.astro";
|
||||
import getSortedPosts from "@/utils/getSortedPosts";
|
||||
import { getPath } from "@/utils/getPath";
|
||||
|
||||
type Props = {
|
||||
post: CollectionEntry<"events">;
|
||||
};
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getCollection("events", ({ data }) => !data.draft);
|
||||
const postResult = posts.map(post => ({
|
||||
params: { slug: getPath(post.id, post.filePath, false) },
|
||||
props: { post },
|
||||
}));
|
||||
|
||||
return postResult;
|
||||
}
|
||||
|
||||
const { post } = Astro.props;
|
||||
|
||||
const posts = await getCollection("events");
|
||||
const sortedPosts = getSortedPosts(posts);
|
||||
---
|
||||
|
||||
<PostDetails post={post} posts={sortedPosts} />
|
||||
32
src/pages/news/[...page].astro
Normal file
32
src/pages/news/[...page].astro
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
import type { GetStaticPaths } from "astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import Main from "@/layouts/Main.astro";
|
||||
import Layout from "@/layouts/Layout.astro";
|
||||
import Header from "@/components/Header.astro";
|
||||
import Footer from "@/components/Footer.astro";
|
||||
import Card from "@/components/Card.astro";
|
||||
import Pagination from "@/components/Pagination.astro";
|
||||
import getSortedPosts from "@/utils/getSortedPosts";
|
||||
import { SITE } from "@/config";
|
||||
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
const news = await getCollection("news", ({ data }) => !data.draft);
|
||||
return paginate(getSortedPosts(news), { pageSize: SITE.postPerPage });
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
const { page } = Astro.props;
|
||||
---
|
||||
|
||||
<Layout title={`News | ${SITE.title}`}>
|
||||
<Header />
|
||||
<Main pageTitle="News" pageDesc="Latest news and updates from HEC IA.">
|
||||
<ul>
|
||||
{page.data.map(data => <Card {...data} />)}
|
||||
</ul>
|
||||
</Main>
|
||||
|
||||
<Pagination {page} />
|
||||
|
||||
<Footer noMarginTop={page.lastPage > 1} />
|
||||
</Layout>
|
||||
27
src/pages/news/[...slug]/index.astro
Normal file
27
src/pages/news/[...slug]/index.astro
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import PostDetails from "@/layouts/PostDetails.astro";
|
||||
import getSortedPosts from "@/utils/getSortedPosts";
|
||||
import { getPath } from "@/utils/getPath";
|
||||
|
||||
type Props = {
|
||||
post: CollectionEntry<"news">;
|
||||
};
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getCollection("news", ({ data }) => !data.draft);
|
||||
const postResult = posts.map(post => ({
|
||||
params: { slug: getPath(post.id, post.filePath, false) },
|
||||
props: { post },
|
||||
}));
|
||||
|
||||
return postResult;
|
||||
}
|
||||
|
||||
const { post } = Astro.props;
|
||||
|
||||
const posts = await getCollection("news");
|
||||
const sortedPosts = getSortedPosts(posts);
|
||||
---
|
||||
|
||||
<PostDetails post={post} posts={sortedPosts} />
|
||||
32
src/pages/technical/[...page].astro
Normal file
32
src/pages/technical/[...page].astro
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
import type { GetStaticPaths } from "astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import Main from "@/layouts/Main.astro";
|
||||
import Layout from "@/layouts/Layout.astro";
|
||||
import Header from "@/components/Header.astro";
|
||||
import Footer from "@/components/Footer.astro";
|
||||
import Card from "@/components/Card.astro";
|
||||
import Pagination from "@/components/Pagination.astro";
|
||||
import getSortedPosts from "@/utils/getSortedPosts";
|
||||
import { SITE } from "@/config";
|
||||
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
const technical = await getCollection("technical", ({ data }) => !data.draft);
|
||||
return paginate(getSortedPosts(technical), { pageSize: SITE.postPerPage });
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
const { page } = Astro.props;
|
||||
---
|
||||
|
||||
<Layout title={`Technical Deep Dives | ${SITE.title}`}>
|
||||
<Header />
|
||||
<Main pageTitle="Technical Deep Dives" pageDesc="In-depth technical articles on AI and machine learning.">
|
||||
<ul>
|
||||
{page.data.map(data => <Card {...data} />)}
|
||||
</ul>
|
||||
</Main>
|
||||
|
||||
<Pagination {page} />
|
||||
|
||||
<Footer noMarginTop={page.lastPage > 1} />
|
||||
</Layout>
|
||||
27
src/pages/technical/[...slug]/index.astro
Normal file
27
src/pages/technical/[...slug]/index.astro
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import PostDetails from "@/layouts/PostDetails.astro";
|
||||
import getSortedPosts from "@/utils/getSortedPosts";
|
||||
import { getPath } from "@/utils/getPath";
|
||||
|
||||
type Props = {
|
||||
post: CollectionEntry<"technical">;
|
||||
};
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getCollection("technical", ({ data }) => !data.draft);
|
||||
const postResult = posts.map(post => ({
|
||||
params: { slug: getPath(post.id, post.filePath, false) },
|
||||
props: { post },
|
||||
}));
|
||||
|
||||
return postResult;
|
||||
}
|
||||
|
||||
const { post } = Astro.props;
|
||||
|
||||
const posts = await getCollection("technical");
|
||||
const sortedPosts = getSortedPosts(posts);
|
||||
---
|
||||
|
||||
<PostDetails post={post} posts={sortedPosts} />
|
||||
32
src/pages/workshops/[...page].astro
Normal file
32
src/pages/workshops/[...page].astro
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
import type { GetStaticPaths } from "astro";
|
||||
import { getCollection } from "astro:content";
|
||||
import Main from "@/layouts/Main.astro";
|
||||
import Layout from "@/layouts/Layout.astro";
|
||||
import Header from "@/components/Header.astro";
|
||||
import Footer from "@/components/Footer.astro";
|
||||
import Card from "@/components/Card.astro";
|
||||
import Pagination from "@/components/Pagination.astro";
|
||||
import getSortedPosts from "@/utils/getSortedPosts";
|
||||
import { SITE } from "@/config";
|
||||
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
const workshops = await getCollection("workshops", ({ data }) => !data.draft);
|
||||
return paginate(getSortedPosts(workshops), { pageSize: SITE.postPerPage });
|
||||
}) satisfies GetStaticPaths;
|
||||
|
||||
const { page } = Astro.props;
|
||||
---
|
||||
|
||||
<Layout title={`Workshops | ${SITE.title}`}>
|
||||
<Header />
|
||||
<Main pageTitle="Workshops" pageDesc="Hands-on technical workshops on AI topics.">
|
||||
<ul>
|
||||
{page.data.map(data => <Card {...data} />)}
|
||||
</ul>
|
||||
</Main>
|
||||
|
||||
<Pagination {page} />
|
||||
|
||||
<Footer noMarginTop={page.lastPage > 1} />
|
||||
</Layout>
|
||||
27
src/pages/workshops/[...slug]/index.astro
Normal file
27
src/pages/workshops/[...slug]/index.astro
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import PostDetails from "@/layouts/PostDetails.astro";
|
||||
import getSortedPosts from "@/utils/getSortedPosts";
|
||||
import { getPath } from "@/utils/getPath";
|
||||
|
||||
type Props = {
|
||||
post: CollectionEntry<"workshops">;
|
||||
};
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getCollection("workshops", ({ data }) => !data.draft);
|
||||
const postResult = posts.map(post => ({
|
||||
params: { slug: getPath(post.id, post.filePath, false) },
|
||||
props: { post },
|
||||
}));
|
||||
|
||||
return postResult;
|
||||
}
|
||||
|
||||
const { post } = Astro.props;
|
||||
|
||||
const posts = await getCollection("workshops");
|
||||
const sortedPosts = getSortedPosts(posts);
|
||||
---
|
||||
|
||||
<PostDetails post={post} posts={sortedPosts} />
|
||||
Reference in New Issue
Block a user