Skillpedia
المواقع والواجهات (frontend)48k · #3828

astro

ما الذي تفعله

Astro إطار عمل لبناء مواقع سريعة تركز على المحتوى. يرسل كمية قليلة جدًا من JavaScript إلى المتصفح، فتصبح الصفحات أخف وأسرع. ويمكنك استخدام تقنيات برمجية مختلفة معًا.

متى تستخدمها

  • ✓عندما تبني مدونة أو موقع توثيق أو ملفًا شخصيًا لأعمالك.
  • ✓عندما تعطي الأولوية لسرعة الموقع وأدائه.
  • ✓عندما تعمل مع كمية كبيرة من النصوص وملفات المحتوى.

رابط المهارة

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/astro/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/astro/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“كيف أنشئ موقع مدونة باستخدام Astro؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

تكتب المحتوى وبنية الموقع في ملفات «.astro». يحوّل Astro كل شيء إلى HTML عادي، ويرسل JavaScript فقط للأجزاء التفاعلية عند الحاجة. وينظم المحتوى والصفحات تلقائيًا.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Astro Web Framework

Overview

Astro is a web framework designed for content-rich websites — blogs, docs, portfolios, marketing sites, and e-commerce. Its core innovation is the Islands Architecture: by default, Astro ships zero JavaScript to the browser. Interactive components are selectively hydrated as isolated "islands." Astro supports React, Vue, Svelte, Solid, and other UI frameworks simultaneously in the same project, letting you pick the right tool per component.

When to Use This Skill

  • Use when building a blog, documentation site, marketing page, or portfolio
  • Use when performance and Core Web Vitals are the top priority
  • Use when the project is content-heavy with Markdown or MDX files
  • Use when you want SSG (static) output with optional SSR for dynamic routes
  • Use when the user asks about .astro files, Astro.props, content collections, or client: directives

How It Works

Step 1: Project Setup

npm create astro@latest my-site
cd my-site
npm install
npm run dev

Add integrations as needed:

npx astro add tailwind        # Tailwind CSS
npx astro add react           # React component support
npx astro add mdx             # MDX support
npx astro add sitemap         # Auto sitemap.xml
npx astro add vercel          # Vercel SSR adapter

Project structure:

src/
  pages/          ← File-based routing (.astro, .md, .mdx)
  layouts/        ← Reusable page shells
  components/     ← UI components (.astro, .tsx, .vue, etc.)
  content/        ← Type-safe content collections (Markdown/MDX)
  styles/         ← Global CSS
public/           ← Static assets (copied as-is)
astro.config.mjs  ← Framework config

Step 2: Astro Component Syntax

.astro files have a code fence at the top (server-only) and a template below:

---
// src/components/Card.astro
// This block runs on the server ONLY — never in the browser
interface Props {
  title: string;
  href: string;
  description: string;
}

const { title, href, description } = Astro.props;
---

<article class="card">
  <h2><a href={href}>{title}</a></h2>
  <p>{description}</p>
</article>

<style>
  /* Scoped to this component automatically */
  .card { border: 1px solid #eee; padding: 1rem; }
</style>

Step 3: File-Based Pages and Routing

src/pages/index.astro          → /
src/pages/about.astro          → /about
src/pages/blog/[slug].astro    → /blog/:slug (dynamic)
src/pages/blog/[...path].astro → /blog/* (catch-all)

Dynamic route with getStaticPaths:

---
// src/pages/blog/[slug].astro
export async function getStaticPaths() {
  const posts = await getCollection('blog');
  return posts.map(post => ({
    params: { slug: post.slug },
    props: { post },
  }));
}

const { post } = Astro.props;
const { Content } = await post.render();
---

<h1>{post.data.title}</h1>
<Content />

Step 4: Content Collections

Content collections give you type-safe access to Markdown and MDX files:

// src/content/config.ts
import { z, defineCollection } from 'astro:content';

const blog = defineCollection({
  type: 'content',
  schema: z.object({
    title: z.string(),
    date: z.coerce.date(),
    tags: z.array(z.string()).default([]),
    draft: z.boolean().default(false),
  }),
});

export const collections = { blog };
---
// src/pages/blog/index.astro
import { getCollection } from 'astro:content';

const posts = (await getCollection('blog'))
  .filter(p => !p.data.draft)
  .sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
---

<ul>
  {posts.map(post => (
    <li>
      <a href={`/blog/${post.slug}`}>{post.data.title}</a>
      <time>{post.data.date.toLocaleDateString()}</time>
    </li>
  ))}
</ul>

Step 5: Islands — Selective Hydration

By default, UI framework components render to static HTML with no JS. Use client: directives to hydrate:

---
import Counter from '../components/Counter.tsx';  // React component
import VideoPlayer from '../components/VideoPlayer.svelte';
---

<!-- Static HTML — no JavaScript sent to browser -->
<Counter initialCount={0} />

<!-- Hydrate immediately on page load -->
<Counter initialCount={0} client:load />

<!-- Hydrate when the component scrolls into view -->
<VideoPlayer src="/demo.mp4" client:visible />

<!-- Hydrate only when browser is idle -->
<Analytics client:idle />

<!-- Hydrate only on a specific media query -->
<MobileMenu client:media="(max-width: 768px)" />

…

الأسئلة الشائعة

ما هي «الجزر» (islands) في Astro؟

هي مكونات تفاعلية تحمّل JavaScript الخاص بها بشكل مستقل، دون التأثير على بقية الصفحة. وهذا يساعد على إبقاء الموقع سريعًا.

هل يمكنني استخدام React أو Vue مع Astro؟

نعم، يتيح Astro استخدام مكونات من مكتبات مختلفة، مثل React وVue وSvelte، داخل المشروع نفسه.

كيف يتعامل Astro مع المحتوى؟

يملك نظامًا يُسمى «Content Collections» ينظم ملفات المحتوى، مثل Markdown وMDX، ويتحقق من صحتها بأمان.

التفاصيل

الوصف الأصلي من المؤلف

Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

repo: sickn33/agentic-awesome-skills

الشعبية

نجوم GitHub
48k
الترتيب
#3828
الترخيص
MIT
آخر تحديث
15‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة