mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 03:32:51 +02:00
update: migrate from content.ts to content.config.ts
This commit is contained in:
parent
9cfd0cb049
commit
4c8dff619e
10 changed files with 302 additions and 329 deletions
|
@ -1,6 +1,6 @@
|
|||
import type { CollectionEntry } from 'astro:content'
|
||||
import { defaultLocale } from '@/config'
|
||||
import { getCollection } from 'astro:content'
|
||||
import { getCollection, render } from 'astro:content'
|
||||
|
||||
// Type definitions
|
||||
export type Post = CollectionEntry<'posts'> & {
|
||||
|
@ -11,7 +11,7 @@ export type Post = CollectionEntry<'posts'> & {
|
|||
|
||||
// Add metadata including reading time to post
|
||||
async function addMetaToPost(post: CollectionEntry<'posts'>): Promise<Post> {
|
||||
const { remarkPluginFrontmatter } = await post.render()
|
||||
const { remarkPluginFrontmatter } = await render(post)
|
||||
return { ...post, remarkPluginFrontmatter: remarkPluginFrontmatter as { minutes: number } }
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ export async function checkPostSlugDuplication(posts: CollectionEntry<'posts'>[]
|
|||
|
||||
posts.forEach((post) => {
|
||||
const lang = post.data.lang
|
||||
const slug = post.data.abbrlink || post.slug
|
||||
const slug = post.data.abbrlink || post.id
|
||||
|
||||
if (!slugMap.has(lang)) {
|
||||
slugMap.set(lang, new Set())
|
||||
|
|
|
@ -70,5 +70,5 @@ export function generateDescription(
|
|||
return post.data.description
|
||||
|
||||
const lang = (!post.data.lang || post.data.lang === '') ? defaultLocale : post.data.lang
|
||||
return generateExcerpt(post.body, scene, lang)
|
||||
return generateExcerpt(post.body || '', scene, lang)
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ export async function generateRSS({ lang }: GenerateRSSOptions = {}) {
|
|||
title: post.data.title,
|
||||
// Generate URL with language prefix and abbrlink/slug
|
||||
link: new URL(
|
||||
`${post.data.lang !== defaultLocale && post.data.lang !== '' ? `${post.data.lang}/` : ''}posts/${post.data.abbrlink || post.slug}/`,
|
||||
`${post.data.lang !== defaultLocale && post.data.lang !== '' ? `${post.data.lang}/` : ''}posts/${post.data.abbrlink || post.id}/`,
|
||||
url,
|
||||
).toString(),
|
||||
description: generateDescription(post, 'rss'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue