diff options
author | 2025-06-05 14:25:23 +0000 | |
---|---|---|
committer | 2025-06-05 14:25:23 +0000 | |
commit | e586d7d704d475afe3373a1de6ae20d504f79d6d (patch) | |
tree | 7e3fa24807cebd48a86bd40f866d792181191ee9 /examples/starlog/src/pages | |
download | astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.tar.gz astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.tar.zst astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.zip |
Sync from a8e1c0a7402940e0fc5beef669522b315052df1blatest
Diffstat (limited to 'examples/starlog/src/pages')
-rw-r--r-- | examples/starlog/src/pages/index.astro | 36 | ||||
-rw-r--r-- | examples/starlog/src/pages/releases/[slug].astro | 21 |
2 files changed, 57 insertions, 0 deletions
diff --git a/examples/starlog/src/pages/index.astro b/examples/starlog/src/pages/index.astro new file mode 100644 index 000000000..3cf04af62 --- /dev/null +++ b/examples/starlog/src/pages/index.astro @@ -0,0 +1,36 @@ +--- +import { getCollection, render } from 'astro:content'; +import FormattedDate from '../components/FormattedDate.astro'; +import Layout from '../layouts/IndexLayout.astro'; + +const posts = await getCollection('releases'); +posts.sort((a, b) => +b.data.date - +a.data.date); +--- + +<Layout> + <main> + <h1 class="page_title">Changelog</h1> + <hr /> + <ul class="posts" transition:name="post"> + { + posts.map((post) => ( + <li class="post"> + <div class="version_wrapper"> + <div class="version_info"> + <a href={`/releases/${post.id}`}> + <div class="version_number">{post.data.versionNumber}</div> + <FormattedDate class="date" date={post.data.date} /> + </a> + </div> + </div> + <div class="content"> + {render(post).then(({ Content }) => ( + <Content /> + ))} + </div> + </li> + )) + } + </ul> + </main> +</Layout> diff --git a/examples/starlog/src/pages/releases/[slug].astro b/examples/starlog/src/pages/releases/[slug].astro new file mode 100644 index 000000000..8c3119a8f --- /dev/null +++ b/examples/starlog/src/pages/releases/[slug].astro @@ -0,0 +1,21 @@ +--- +import { getCollection, render } from 'astro:content'; +import Layout from '../../layouts/PostLayout.astro'; + +export async function getStaticPaths() { + const releases = await getCollection('releases'); + + return releases.map((release) => ({ + params: { slug: release.id }, + props: { release }, + })); +} + +const { release } = Astro.props; + +const { Content } = await render(release); +--- + +<Layout {release}> + <Content /> +</Layout> |