0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Update examples for v5 (#12588)

* Revert "chore: downgrade examples to not use beta releases (#12557)"

This reverts commit 6031962ab5.

* Update blog template for new content collections

* Update portfolio template for new content collections

* Update starlog template for new content collections
This commit is contained in:
Chris Swithinbank 2024-12-03 11:00:43 +01:00 committed by GitHub
parent 1dc8f5eb7c
commit 3a144b1a69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 143 additions and 832 deletions

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.16.16"
"astro": "^5.0.0-beta.12"
}
}

View file

@ -10,9 +10,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^3.1.9",
"@astrojs/mdx": "^4.0.0-beta.5",
"@astrojs/rss": "^4.0.9",
"@astrojs/sitemap": "^3.2.1",
"astro": "^4.16.16"
"astro": "^5.0.0-beta.12"
}
}

View file

@ -1,7 +1,9 @@
import { glob } from 'astro/loaders';
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
type: 'content',
// Load Markdown and MDX files in the `src/content/blog/` directory.
loader: glob({ base: './src/content/blog', pattern: '**/*.{md,mdx}' }),
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),

View file

@ -1,18 +1,19 @@
---
import { type CollectionEntry, getCollection } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
import { render } from 'astro:content';
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts.map((post) => ({
params: { slug: post.slug },
params: { slug: post.id },
props: post,
}));
}
type Props = CollectionEntry<'blog'>;
const post = Astro.props;
const { Content } = await post.render();
const { Content } = await render(post);
---
<BlogPost {...post.data}>

View file

@ -93,7 +93,7 @@ const posts = (await getCollection('blog')).sort(
{
posts.map((post) => (
<li>
<a href={`/blog/${post.slug}/`}>
<a href={`/blog/${post.id}/`}>
<img width={720} height={360} src={post.data.heroImage} alt="" />
<h4 class="title">{post.data.title}</h4>
<p class="date">

View file

@ -10,7 +10,7 @@ export async function GET(context) {
site: context.site,
items: posts.map((post) => ({
...post.data,
link: `/blog/${post.slug}/`,
link: `/blog/${post.id}/`,
})),
});
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^4.16.16"
"astro": "^5.0.0-beta.12"
},
"peerDependencies": {
"astro": "^4.0.0 || ^5.0.0"

View file

@ -13,6 +13,6 @@
"@astrojs/alpinejs": "^0.4.0",
"@types/alpinejs": "^3.13.10",
"alpinejs": "^3.14.3",
"astro": "^4.16.16"
"astro": "^5.0.0-beta.12"
}
}

View file

@ -10,14 +10,14 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/preact": "^3.5.4",
"@astrojs/react": "^3.6.3",
"@astrojs/solid-js": "^4.4.4",
"@astrojs/svelte": "^6.0.2",
"@astrojs/vue": "^4.5.3",
"@astrojs/preact": "^4.0.0-beta.1",
"@astrojs/react": "^4.0.0-beta.2",
"@astrojs/solid-js": "^5.0.0-beta.1",
"@astrojs/svelte": "^7.0.0-beta.1",
"@astrojs/vue": "^5.0.0-beta.3",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"astro": "^4.16.16",
"astro": "^5.0.0-beta.12",
"preact": "^10.24.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",

View file

@ -10,9 +10,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/preact": "^3.5.4",
"@astrojs/preact": "^4.0.0-beta.1",
"@preact/signals": "^1.3.0",
"astro": "^4.16.16",
"astro": "^5.0.0-beta.12",
"preact": "^10.24.3"
}
}

View file

@ -10,10 +10,10 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/react": "^3.6.3",
"@astrojs/react": "^4.0.0-beta.2",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"astro": "^4.16.16",
"astro": "^5.0.0-beta.12",
"react": "^18.3.1",
"react-dom": "^18.3.1"
}

View file

@ -10,8 +10,8 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/solid-js": "^4.4.4",
"astro": "^4.16.16",
"@astrojs/solid-js": "^5.0.0-beta.1",
"astro": "^5.0.0-beta.12",
"solid-js": "^1.9.3"
}
}

View file

@ -10,8 +10,8 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/svelte": "^6.0.2",
"astro": "^4.16.16",
"@astrojs/svelte": "^7.0.0-beta.1",
"astro": "^5.0.0-beta.12",
"svelte": "^5.1.16"
}
}

View file

@ -10,8 +10,8 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/vue": "^4.5.3",
"astro": "^4.16.16",
"@astrojs/vue": "^5.0.0-beta.3",
"astro": "^5.0.0-beta.12",
"vue": "^3.5.12"
}
}

View file

@ -11,6 +11,6 @@
},
"dependencies": {
"@astrojs/node": "^9.0.0-alpha.1",
"astro": "^4.16.16"
"astro": "^5.0.0-beta.12"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^4.16.16"
"astro": "^5.0.0-beta.12"
},
"peerDependencies": {
"astro": "^4.0.0"

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.16.16"
"astro": "^5.0.0-beta.12"
}
}

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.16.16"
"astro": "^5.0.0-beta.12"
}
}

View file

@ -5,10 +5,10 @@ interface Props {
project: CollectionEntry<'work'>;
}
const { data, slug } = Astro.props.project;
const { data, id } = Astro.props.project;
---
<a class="card" href={`/work/${slug}`}>
<a class="card" href={`/work/${id}`}>
<span class="title">{data.title}</span>
<img src={data.img} alt={data.img_alt || ''} loading="lazy" decoding="async" />
</a>

View file

@ -1,8 +1,10 @@
import { glob } from 'astro/loaders';
import { defineCollection, z } from 'astro:content';
export const collections = {
work: defineCollection({
type: 'content',
// Load Markdown files in the src/content/work directory.
loader: glob({ base: './src/content/work', pattern: '**/*.md', }),
schema: z.object({
title: z.string(),
description: z.string(),

View file

@ -7,6 +7,7 @@ import ContactCTA from '../../components/ContactCTA.astro';
import Hero from '../../components/Hero.astro';
import Icon from '../../components/Icon.astro';
import Pill from '../../components/Pill.astro';
import { render } from 'astro:content';
interface Props {
entry: CollectionEntry<'work'>;
@ -18,13 +19,13 @@ interface Props {
export async function getStaticPaths() {
const work = await getCollection('work');
return work.map((entry) => ({
params: { slug: entry.slug },
params: { slug: entry.id },
props: { entry },
}));
}
const { entry } = Astro.props;
const { Content } = await entry.render();
const { Content } = await render(entry);
---
<BaseLayout title={entry.data.title} description={entry.data.description}>

View file

@ -11,9 +11,9 @@
"server": "node dist/server/entry.mjs"
},
"dependencies": {
"@astrojs/node": "^8.3.4",
"@astrojs/svelte": "^6.0.2",
"astro": "^4.16.16",
"@astrojs/node": "^9.0.0-alpha.1",
"@astrojs/svelte": "^7.0.0-beta.1",
"astro": "^5.0.0-beta.12",
"svelte": "^5.1.16"
}
}

View file

@ -1,6 +1,9 @@
import { glob } from 'astro/loaders';
import { defineCollection, z } from 'astro:content';
const releases = defineCollection({
// Load Markdown files in the src/content/releases directory.
loader: glob({ base: './src/content/releases', pattern: '**/*.md' }),
// Type-check frontmatter using a schema
schema: ({ image }) =>
z.object({

View file

@ -1,5 +1,5 @@
---
import { getCollection } from 'astro:content';
import { getCollection, render } from 'astro:content';
import FormattedDate from '../components/FormattedDate.astro';
import Layout from '../layouts/IndexLayout.astro';
@ -17,14 +17,14 @@ posts.sort((a, b) => +b.data.date - +a.data.date);
<li class="post">
<div class="version_wrapper">
<div class="version_info">
<a href={`/releases/${post.slug}`}>
<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">
{post.render().then(({ Content }) => (
{render(post).then(({ Content }) => (
<Content />
))}
</div>

View file

@ -1,19 +1,19 @@
---
import { getCollection } from 'astro:content';
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.slug },
params: { slug: release.id },
props: { release },
}));
}
const { release } = Astro.props;
const { Content } = await release.render();
const { Content } = await render(release);
---
<Layout {release}>

View file

@ -15,6 +15,6 @@
"./app": "./dist/app.js"
},
"devDependencies": {
"astro": "^4.16.16"
"astro": "^5.0.0-beta.12"
}
}

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/markdoc": "^0.11.5",
"astro": "^4.16.16"
"@astrojs/markdoc": "^0.12.0-beta.1",
"astro": "^5.0.0-beta.12"
}
}

View file

@ -10,9 +10,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^3.1.9",
"@astrojs/preact": "^3.5.4",
"astro": "^4.16.16",
"@astrojs/mdx": "^4.0.0-beta.5",
"@astrojs/preact": "^4.0.0-beta.1",
"astro": "^5.0.0-beta.12",
"preact": "^10.24.3"
}
}

View file

@ -10,9 +10,9 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/preact": "^3.5.4",
"@astrojs/preact": "^4.0.0-beta.1",
"@nanostores/preact": "^0.5.2",
"astro": "^4.16.16",
"astro": "^5.0.0-beta.12",
"nanostores": "^0.11.3",
"preact": "^10.24.3"
}

View file

@ -10,10 +10,10 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^3.1.9",
"@astrojs/mdx": "^4.0.0-beta.5",
"@astrojs/tailwind": "^5.1.2",
"@types/canvas-confetti": "^1.6.4",
"astro": "^4.16.16",
"astro": "^5.0.0-beta.12",
"autoprefixer": "^10.4.20",
"canvas-confetti": "^1.9.3",
"postcss": "^8.4.49",

File diff suppressed because it is too large Load diff