Skip to content

Commit af3e90c

Browse files
Dev-HyunSangclaude
andcommitted
fix: Astro v6 Content Layer API로 마이그레이션
레거시 content config(src/content/config.ts)가 v6에서 제거되어 빌드가 실패했음. glob 로더를 쓰는 src/content.config.ts로 옮기고, 이에 따라 바뀐 entry.id(구 slug)와 render(entry)(구 entry.render()) API에 맞춰 관련 페이지들을 갱신함. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent f5ccd15 commit af3e90c

8 files changed

Lines changed: 14 additions & 13 deletions

File tree

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { defineCollection, z } from 'astro:content';
2+
import { glob } from 'astro/loaders';
23

34
const posts = defineCollection({
4-
type: 'content',
5+
loader: glob({ pattern: '**/*.md', base: './src/content/posts' }),
56
schema: z.object({
67
title: z.string(),
78
subtitle: z.string().optional(),
@@ -16,7 +17,7 @@ const posts = defineCollection({
1617
});
1718

1819
const highlights = defineCollection({
19-
type: 'content',
20+
loader: glob({ pattern: '**/*.md', base: './src/content/highlights' }),
2021
schema: z.object({
2122
title: z.string(),
2223
date: z.coerce.date(),

src/pages/categories/[category].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const { category, posts } = Astro.props;
3232
{posts.map((post) => (
3333
<article class="post-summary">
3434
<h3>
35-
<a href={`/posts/${post.slug}/`}>{post.data.title}</a>
35+
<a href={`/posts/${post.id}/`}>{post.data.title}</a>
3636
</h3>
3737
{post.data.subtitle && <p class="subtitle">{post.data.subtitle}</p>}
3838
<div class="post-meta">

src/pages/highlights/[...slug].astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
import { getCollection } from 'astro:content';
2+
import { getCollection, render } from 'astro:content';
33
import SingleLayout from '../../layouts/SingleLayout.astro';
44
55
export async function getStaticPaths() {
66
const highlights = await getCollection('highlights');
77
return highlights.map((entry) => ({
8-
params: { slug: entry.slug },
8+
params: { slug: entry.id },
99
props: { entry },
1010
}));
1111
}
1212
1313
const { entry } = Astro.props;
14-
const { Content, headings } = await entry.render();
14+
const { Content, headings } = await render(entry);
1515
---
1616

1717
<SingleLayout

src/pages/highlights/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const highlights = (await getCollection('highlights'))
1818
{highlights.map((entry) => (
1919
<article class="post-summary">
2020
<h3>
21-
<a href={`/highlights/${entry.slug}/`}>{entry.data.title}</a>
21+
<a href={`/highlights/${entry.id}/`}>{entry.data.title}</a>
2222
</h3>
2323
{entry.data.showDate !== false && (
2424
<div class="post-meta">

src/pages/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ for (const post of posts) {
6565
<h2>Recent Posts</h2>
6666
<div class="posts-list">
6767
{posts.map((post) => (
68-
<a href={`/posts/${post.slug}/`} class="post-summary-link" data-categories={(post.data.categories ?? []).map(urlize).join(' ')}>
68+
<a href={`/posts/${post.id}/`} class="post-summary-link" data-categories={(post.data.categories ?? []).map(urlize).join(' ')}>
6969
<article class="post-summary">
7070
<h3>{post.data.title}</h3>
7171
{post.data.subtitle && <p class="subtitle">{post.data.subtitle}</p>}

src/pages/posts/[...slug].astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
import { getCollection } from 'astro:content';
2+
import { getCollection, render } from 'astro:content';
33
import SingleLayout from '../../layouts/SingleLayout.astro';
44
55
export async function getStaticPaths() {
66
const posts = await getCollection('posts', ({ data }) => !data.draft);
77
return posts.map((post) => ({
8-
params: { slug: post.slug },
8+
params: { slug: post.id },
99
props: { post },
1010
}));
1111
}
1212
1313
const { post } = Astro.props;
14-
const { Content, headings } = await post.render();
14+
const { Content, headings } = await render(post);
1515
---
1616

1717
<SingleLayout

src/pages/posts/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ for (const post of posts) {
5959
</time>
6060
)}
6161
<h4 class="post-title">
62-
<a href={`/posts/${post.slug}/`}>{post.data.title}</a>
62+
<a href={`/posts/${post.id}/`}>{post.data.title}</a>
6363
</h4>
6464
{post.data.subtitle && <p class="post-subtitle">{post.data.subtitle}</p>}
6565
<div class="post-footer-info">

src/pages/tags/[tag].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const { tag, posts } = Astro.props;
3232
{posts.map((post) => (
3333
<article class="post-summary">
3434
<h3>
35-
<a href={`/posts/${post.slug}/`}>{post.data.title}</a>
35+
<a href={`/posts/${post.id}/`}>{post.data.title}</a>
3636
</h3>
3737
{post.data.subtitle && <p class="subtitle">{post.data.subtitle}</p>}
3838
<div class="post-meta">

0 commit comments

Comments
 (0)