يقدّم Astro 5 جزر الخادم (Server Islands) للترطيب الجزئي الدقيق، ومجموعات محتوى مُحسّنة لإدارة المحتوى المنظّم.
جزر الخادم (Server Islands)
أجّل تحميل المكوّنات المكلفة لتُحمَّل بعد ظهور الصفحة:
---
// Static content renders immediately
import Header from "./Header.astro";
import Comments from "./Comments.astro";
---
<Header />
<main>Static content here</main>
<!-- Server island loads after page -->
<Comments server:defer>
<p slot="fallback">Loading comments...</p>
</Comments>
مجموعات المحتوى (Content Collections)
// src/content/config.ts
import { defineCollection, z } from "astro:content";
const blog = defineCollection({
type: "content",
schema: z.object({
title: z.string(),
pubDate: z.date(),
tags: z.array(z.string()),
}),
});
export const collections = { blog };
استخدام المجموعات
---
import { getCollection } from "astro:content";
const posts = await getCollection("blog", ({ data }) => {
return data.tags.includes("typescript");
});
---
التعليقات (0)
اترك تعليقًا
لا توجد تعليقات بعد. كن أول من يشارك أفكاره!