본문으로 건너뛰기
cccskills
무료GitHub에 공개

astro

Provides expert knowledge for building Astro 5+ sites with Islands Architecture, Content Collections, TypeScript, and performance-first rendering strategies.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md7.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Astro

Islands Architecture

Astro renders everything to static HTML by default. JavaScript ships only for components that explicitly opt in — these are called Islands.

Hydration Directives

DirectiveWhen JS loadsUse case
client:loadOn page loadInteractive above-the-fold UI
client:idleWhen browser is idleNon-critical interactive widgets
client:visibleWhen element enters viewportBelow-the-fold islands
client:mediaWhen CSS media query matchesResponsive interactive components
client:onlyClient-only, no SSRComponents that require the DOM (e.g., charting libs)
---
import Counter from '../components/Counter.tsx';
import HeavyChart from '../components/HeavyChart.tsx';
import MobileNav from '../components/MobileNav.tsx';
---

<!-- Hydrates immediately — user interacts right away -->
<Counter client:load />

<!-- Hydrates when scrolled into view — saves initial JS -->
<HeavyChart client:visible />

<!-- Only on mobile, only when query matches -->
<MobileNav client:media="(max-width: 768px)" />

Rules:

  • Default to no hydration directive — most UI does not need JavaScript
  • client:load is the most expensive directive; use it sparingly
  • client:only skips server rendering entirely — the component receives no props from the server; pass all data via props or fetch inside the component
  • Do not use client:load for components that could use client:visible

Framework Components Inside Astro

---
import ReactButton from './Button.tsx';   // React island
import VueWidget from './Widget.vue';     // Vue island
---

<!-- Both can coexist on the same page -->
<ReactButton client:idle label="Click me" />
<VueWidget client:visible />

Each framework ships its own runtime only when at least one island of that framework is on the page.

Content Collections

Content Collections provide type-safe access to Markdown, MDX, and data files. Define schemas in src/content/config.ts.

Schema Definition

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

const blog = defineCollection({
  type: 'content',   // .md or .mdx files
  schema: z.object({
    title: z.string(),
    description: z.string(),
    pubDate: z.coerce.date(),
    updatedDate: z.coerce.date().optional(),
    author: z.string().default('Anonymous'),
    tags: z.array(z.string()).default([]),
    draft: z.boolean().default(false),
    image: z.object({
      src: z.string(),
      alt: z.string(),
    }).optional(),
  }),
});

const docs = defineCollection({
  type: 'content',
  schema: z.object({
    title: z.string(),
    order: z.number(),
    section: z.enum(['guide', 'reference', 'tutorial']),
  }),
});

export const collections = { blog, docs };

Querying Collections

---
import { getCollection, getEntry } from 'astro:content';

// All published posts, sorted by date
const posts = (await getCollection('blog', ({ data }) => !data.draft))
  .sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());

// Single entry by slug
const post = await getEntry('blog', 'my-first-post');
const { Content } = await post.render();
---

{posts.map(post => (
  <article>
    <h2><a href={`/blog/${post.slug}`}>{post.data.title}</a></h2>
    <time>{post.data.pubDate.toLocaleDateString()}</time>
  </article>
))}

Dynamic Routes from Collections

---
// src/pages/blog/[slug].astro
import { getCollection } from 'astro:content';

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, headings } = await post.render();
---

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

Rendering Strategies

SSG (Static Site Generation) — default

Every page is pre-rendered at build time. Best for content that does not change per request.

// astro.config.mjs — no output config needed; SSG is the default
export default defineConfig({
  site: 'https://example.com',
});

SSR (Server-Side Rendering)

Renders pages on each request. Required for: authenticated routes, personalized content, live data.

// astro.config.mjs
import node from '@astrojs/node';

export default defineConfig({
  output: 'server',
  adapter: node({ mode: 'standalone' }),
});

Hybrid Mode

Mix SSG and SSR on a per-page basis. Most pages are static; specific routes opt into server rendering.

// astro.config.mjs
export default defineConfig({
  output: 'hybrid',
  adapter: node({ mode: 'standalone' }),
});
---
// src/pages/dashboard.astro — this page is server-rendered
export const prerender = false;

// src/pages/about.astro — this page is statically generated (hybrid default)
export const prerender = true;
---

Use hybrid mode when: most content is static but a few routes need auth or live data. Do not make everything output: 'server' — you lose the performance benefits of static generation.

Image Optimization

Use the built-in <Image> and <Picture> components. Never use raw <img> for local assets — you lose automatic optimization.

---
import { Image, Picture } from 'astro:assets';
import heroImage from '../assets/hero.png';
---

<!-- Optimized single image -->
<Image
  src={heroImage}
  alt="Hero illustration"
  width={800}
  height={600}
  format="webp"
  quality={80}
/>

<!-- Responsive with multiple formats -->
<Picture
  src={heroImage}
  formats={['avif', 'webp']}
  alt="Hero illustration"
  widths={[400, 800, 1200]}
  sizes="(max-width: 800px) 100vw, 800px"
/>

Rules:

  • Always provide alt — empty string is acceptable only for decorative images
  • Prefer avif + webp fallback for best compression
  • Use widths + sizes on above-the-fold images to serve the right size per viewport
  • Remote images require explicit width and height to prevent layout shift

Project Structure

src/
  assets/          — images and static assets processed by Astro
  components/      — .astro components (and framework islands)
  content/
    blog/          — .md and .mdx files
    config.ts      — collection schemas
  layouts/         — page shell layouts
  pages/           — file-based routing; every file is a route
  styles/          — global CSS
astro.config.mjs
tsconfig.json

Colocation rule: put framework island components (.tsx, .vue) in src/components/. Do not scatter them in src/pages/.

TypeScript Conventions

// tsconfig.json — use the strict Astro preset
{
  "extends": "astro/tsconfigs/strict"
}
---
// Type props explicitly in the frontmatter
interface Props {
  title: string;
  description?: string;
  tags: string[];
}

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

Astro infers prop types from interface Props automatically. Do not use any.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when adding monitoring, metrics, logging, or tracing to Spring AI or LLM integration code. Covers token tracking, latency measurement, cost estimation, and prompt/response logging. Use when user mentions AI monitoring, token costs, or LLM observability.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

lgzarturo/springboot-course32026년 10월 20일 업데이트

android

무료

Provides expert knowledge for building modern native Android apps using Kotlin, Jetpack Compose, Material Design 3, MVI architecture, Hilt dependency injection, and Media3/ExoPlayer.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

lgzarturo/springboot-course32026년 10월 20일 업데이트

Design, implement, review, and audit Android Jetpack Compose UI/UX for phone interfaces. Use when a request concerns concrete Compose layout, components, interaction, accessibility, or visual behavior. Do not activate for framework or dependency presence alone; non-UI Android work is excluded.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

lgzarturo/springboot-course32026년 10월 20일 업데이트

Provides expert knowledge for designing, implementing, and managing REST API versioning strategies with deprecation workflows.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

lgzarturo/springboot-course32026년 10월 20일 업데이트

Audits token storage mechanisms to prevent XSS-based JWT theft.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

lgzarturo/springboot-course32026년 10월 20일 업데이트

Provides patterns to configure AWS RDS (Aurora, MySQL, PostgreSQL) with Spring Boot applications. Configures HikariCP connection pools, implements read/write splitting, sets up IAM database authentication, enables SSL connections, and integrates with AWS Secrets Manager. Use when setting up RDS connections in Spring Boot, configuring connection pooling, or managing database credentials securely.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

lgzarturo/springboot-course32026년 10월 20일 업데이트

lgzarturo의 스킬 모두 보기

이 스킬의 문제 신고