Communitygithub.com

asolis87/complementary-food-app

Astro のランディングページ、コンテンツサイト、SSGプロジェクト向け規約。Vera Sesiom のスタンダード。デフォルトでZero JS、インタラクティブ部分にはVue Islands、コンテンツファーストのアーキテクチャ。

complementary-food-app とは?

このスキルは、Astro フレームワークを使用して、SEOとパフォーマンスが重要なランディングページ、マーケティングサイト、ブログ、ドキュメントなどのコンテンツ重視の静的サイトを構築するための規約とパターンを提供します。デフォルトでJavaScriptを一切出荷せず、必要な部分にのみVue/Reactコンポーネントを「アイランド」として追加する「アイランドアーキテクチャ」を採用しています。具体的には、厳格なTypeScriptの使用、Tailwind CSS によるスタイリング、Zod スキーマによるコンテンツコレクションの定義、`astro:assets` による画像最適化、そしてSEOパターンを徹底。Claude Code、Cursor、Codex などのAIエージェントで利用でき、`apps/landing/` のようなスクリーミングアーキテクチャのプロジェクト構成を推奨し、サイトの目的(「読む」サイト vs 「使う」アプリ)に応じてAstroとVueを使い分ける明確な判断基準を定義しています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/asolis87/complementary-food-app/tree/HEAD/.agents/skills/astro-landing

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

使用するタイミング

  • ランディングページやマーケティングサイト
  • コーポレートサイト
  • コンテンツ重視のサイト(ブログ、ドキュメント)
  • SEOとパフォーマンスが重要なプロジェクト
  • ほとんどが静的で、インタラクションが最小限のサイト
  • 高速な初回読み込みとCore Web Vitalsが必要なサイト

本格的なWebアプリには使用しないでください — インタラクティブなアプリケーション(ダッシュボード、CRUDアプリ、リアルタイムアプリ)には vue-frontend を使用してください。


重要なルール

  1. デフォルトでZero JS — Astroは、client:* ディレクティブを追加しない限り、JavaScriptを一切出荷しません。
  2. 常にTypeScript — すべてのVera Sesiomプロジェクトと同様、strictモードを使用します。
  3. 構造化コンテンツにはContent Collectionsを使用 — ブログ記事、ドキュメント、ケーススタディなど。
  4. アイランドアーキテクチャ — Vue/Reactコンポーネントは、インタラクションが必要な場合にのみ使用します。
  5. デフォルトで静的出力(SSG) — 動的コンテンツが必要な場合にのみSSRを使用します。
  6. スタイリングにはTailwind CSSを使用 — Vueフロントエンドと同様です。
  7. スクリーミングアーキテクチャ — フォルダ名はフレームワークではなくドメインを表します。

判断基準: Astro vs Vue

Astroを使用する場合Vueを使用する場合
ランディングページ、マーケティングサイトWebアプリケーション(ダッシュボード、管理画面)
コンテンツ重視(ブログ、ドキュメント)高度にインタラクティブなUI
SEOが重要リアルタイム機能が必要
ほぼ静的なコンテンツ複雑な状態管理
最小限のインタラクション(フォーム、カルーセル)フルSPAナビゲーション
Zero JSが利点Vueエコシステムの恩恵が重要

ルール: サイトが人々が読むコンテンツであれば → Astro。アプリを人々が使うのであれば → Vue。


プロジェクト構造(スクリーミングアーキテクチャ)

apps/landing/   (または apps/website/)
├── src/
│   ├── pages/                    # ファイルベースルーティング(.astroファイル)
│   │   ├── index.astro           # ホームページ
│   │   ├── about.astro           # アバウトページ
│   │   ├── pricing.astro         # プライシングページ
│   │   ├── blog/
│   │   │   ├── index.astro      # ブログ一覧
│   │   │   └── [slug].astro      # ブログ記事(動的)
│   │   └── contact.astro
│   ├── layouts/                  # ページレイアウト
│   │   ├── BaseLayout.astro      # ベースHTML構造
│   │   ├── BlogLayout.astro      # ブログ記事レイアウト
│   │   └── LandingLayout.astro   # ランディングページレイアウト
│   ├── components/               # Astroコンポーネント(デフォルトで静的)
│   │   ├── sections/             # ページセクション
│   │   │   ├── Hero.astro
│   │   │   ├── Features.astro
│   │   │   ├── Pricing.astro
│   │   │   ├── Testimonials.astro
│   │   │   └── CTA.astro
│   │   ├── ui/                   # 再利用可能なUIアトム
│   │   │   ├── Button.astro
│   │   │   ├── Card.astro
│   │   │   ├── Badge.astro
│   │   │   └── Input.astro
│   │   └── interactive/          # Vue/Reactアイランド
│   │       ├── ContactForm.vue   # バリデーション付きフォーム
│   │       ├── Carousel.vue      # 画像カルーセル
│   │       └── MobileMenu.vue    # モバイルナビゲーション
│   ├── content/                  # コンテンツコレクション
│   │   ├── blog/                 # Markdown/MDXブログ記事
│   │   │   ├── post-1.md
│   │   │   └── post-2.mdx
│   │   └── config.ts             # コレクションスキーマ(Zod)
│   ├── styles/                   # グローバルスタイル
│   │   └── global.css            # Tailwindインポート
│   ├── assets/                   # 最適化された画像、フォント
│   │   ├── images/
│   │   └── fonts/
│   └── utils/                    # ヘルパー関数
│       ├── date-format.ts
│       └── seo.ts
├── public/                       # 静的アセット(処理なし)
│   ├── favicon.ico
│   ├── robots.txt
│   └── fonts/
├── astro.config.mjs              # Astro設定
├── tailwind.config.mjs           # Tailwind設定
├── tsconfig.json
└── package.json

Astroコンポーネントパターン

すべての .astro ファイルには、frontmatter(サーバーサイド)とテンプレート(HTML)の2つの部分があります。

---
// src/components/ui/Button.astro
// Frontmatter: サーバーサイドで実行、ブラウザJSはなし

export interface Props {
  variant?: 'primary' | 'secondary' | 'outline'
  size?: 'sm' | 'md' | 'lg'
  href?: string
}

const {
  variant = 'primary',
  size = 'md',
  href,
  ...rest
} = Astro.props

const baseClasses = 'inline-flex items-center justify-center font-medium rounded-lg transition-colors'
const variantClasses = {
  primary: 'bg-blue-600 text-white hover:bg-blue-700',
  secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
  outline: 'border-2 border-blue-600 text-blue-600 hover:bg-blue-50'
}
const sizeClasses = {
  sm: 'px-3 py-1.5 text-sm',
  md: 'px-4 py-2 text-base',
  lg: 'px-6 py-3 text-lg'
}

const classes = `${baseClasses} ${variantClasses[variant]} ${sizeClasses[size]}`
---

{href ? (
  <a href={href} class={classes} {...rest}>
    <slot />
  </a>
) : (
  <button class={classes} {...rest}>
    <slot />
  </button>
)}

重要なポイント:

  • frontmatterはビルド時(またはSSRの場合はリクエスト時)に実行されます
  • export default は不要 — テンプレート自体がエクスポートです
  • 子コンテンツには <slot /> を使用します
  • PropsはTypeScriptインターフェースで型付けされます

レイアウトパターン

---
// src/layouts/BaseLayout.astro
import Nav from '../components/Nav.astro'
import Footer from '../components/Footer.astro'

export interface Props {
  title: string
  description?: string
  image?: string
}

const { title, description = '', image = '/og-default.png' } = Astro.props
const canonicalURL = new URL(Astro.url.pathname, Astro.site)
---

<html lang="ja">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="canonical" href={canonicalURL} />
    <title>{title}</title>
    <meta name="description" content={description} />
    
    <!-- OpenGraph -->
    <meta property="og:title" content={title} />
    <meta property="og:description" content={description} />
    <meta property="og:image" content={image} />
    <meta property="og:url" href={canonicalURL} />
    <meta property="og:type" content="website" />
    
    <!-- Twitter -->
    <meta name="twitter:card" content="summary_large_image" />
    
    <slot name="head" />
  </head>
  <body class="bg-white text-gray-900 antialiased">
    <Nav />
    <main>
      <slot />
    </main>
    <Footer />
  </body>
</html>

使用例:

---
// src/pages/index.astro
import BaseLayout from '../layouts/BaseLayout.astro'
import Hero from '../components/sections/Hero.astro'
---

<BaseLayout title="Vera Sesiom - ソフトウェア開発" description="私たちは意味のあるソフトウェアを構築します。">
  <Hero />
</BaseLayout>

コンテンツコレクションパターン

Zodスキーマ検証で構造化コンテンツを定義します。

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

const blogCollection = defineCollection({
  type: 'content',
  schema: z.object({
    title: z.string(),
    description: z.string(),
    pubDate: z.coerce.date(),
    updatedDate: z.coerce.date().optional(),
    author: z.string().default('Vera Sesiom'),
    image: z.object({
      url: z.string(),
      alt: z.string()
    }).optional(),
    tags: z.array(z.string()).default([]),
    draft: z.boolean().default(false)
  })
})

export const collections = {
  blog: blogCollection
}
---
title: "ランディングページにAstroを選んだ理由"
description: "パフォーマンスと開発者体験は重要です。Astroがコンテンツサイトで私たちの第一選択である理由をご紹介します。"
pubDate: 2024-01-15
author: "テックリード"
image:
  url: "/images/blog/astro-landing.jpg"
  alt: "モダンなウェブサイト上のAstroロゴ"
tags: ["astro", "performance", "architecture"]
---

ここにコンテンツが入ります...
---
// src/pages/blog/index.astro
import { getCollection } from 'astro:content'
import BaseLayout from '../../layouts/BaseLayout.astro'

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

<BaseLayout title="ブログ" description="Vera Sesiomの最新記事">
  <h1>ブログ</h1>
  <ul>
    {posts.map(post => (
      <li>
        <a href={`/blog/${post.slug}`}>
          <h2>{post.data.title}</h2>
          <p>{post.data.description}</p>
          <time>{post.data.pubDate.toLocaleDateString()}</time>
        </a>
      </li>
    ))}
  </ul>
</BaseLayout>
---
// src/pages/blog/[slug].astro
import { getCollection } from 'astro:content'
import BaseLayout from '../../layouts/BaseLayout.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()
---

<BaseLayout title={post.data.title} description={post.data.description}>
  <article>
    <header>
      <h1>{post.data.title}</h1>
      <time>{post.data.pubDate.toLocaleDateString()}</time>
      <p>投稿者: {post.data.author}</p>
    </header>
    <Content />
  </article>
</BaseLayout>

アイランドアーキテクチャ(Vueコンポーネント)

インタラクティブなコンポーネントは、必要な場合にのみJSを出荷します。クライアントディレクティブを使用してハイドレーションを制御します。

<!-- src/components/interactive/ContactForm.vue -->
<script setup lang="ts">
import { ref, computed } from 'vue'

const form = ref({
  name: '',
  email: '',
  message: ''
})

const errors = ref<Record<string, string>>({})

const isValid = computed(() => {
  return form.value.name && 
         form.value.email.includes('@') && 
         form.value.message.length > 10
})

async function submitForm() {
  if (!isValid.value) return
  
  // APIに送信
  const response = await fetch('/api/contact', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(form.value)
  })
  
  if (response.ok) {
    // 成功時の処理
    form.value = { name: '', email: '', message: '' }
  }
}
</script>

<template>
  <form @submit.prevent="submitForm" class="space-y-4">
    <div>
      <label for="name">名前</label>
      <input v-model="form.name" type="text" id="name" required />
    </div>
    <div>
      <label for="email">メールアドレス</label>
      <input v-model="form.email" type="email" id="email" required />
    </div>
    <div>
      <label for="message">メッセージ</label>
      <textarea v-model="form.message" id="message" rows="4" required />
    </div>
    <button type="submit" :disabled="!isValid">
      メッセージを送信
    </button>
  </form>
</template>

Astro内での使用:

---
// src/pages/contact.astro
import BaseLayout from '../layouts/BaseLayout.astro'
import ContactForm from '../components/interactive/ContactForm.vue'
---

<BaseLayout title="お問い合わせ">
  <h1>お問い合わせ</h1>
  <p>ご連絡をお待ちしております。</p>
  
  <!-- client:visible = スクロールして表示されたときにハイドレート(ベストプラクティス) -->
  <ContactForm client:visible />
</BaseLayout>

クライアントディレクティブ決定木

ディレクティブ使用するタイミングJSの出荷タイミング
ディレクティブなし静的なコンテンツ、インタラクションなしZero JS
client:visible画面外のインタラクション(フォーム、カルーセル) — デフォルトスクロールして表示されたとき
client:load画面内の重要なインタラクション即時
client:idle重要でない拡張機能(アナリティクス、チャット)ページがアイドル状態になった後
client:mediaブレークポイントによる条件付き(モバイルナビ)メディアクエリが一致したとき
client:onlySPAライクなコンポーネント(SSRをスキップ)即時、SSRなし

ベストプラクティス:

  • デフォルトは ディレクティブなし — 純粋に静的
  • インタラクションが必要な場合のデフォルトは client:visible
  • client:load は控えめに — 画面内の重要なもののみ
  • ブロッキングしない拡張機能には client:idle を使用
---
<!-- 良い例 -->
import Hero from './Hero.astro'                    <!-- 静的、JSなし -->
import Carousel from './Carousel.vue'             
import MobileMenu from './MobileMenu.vue'         
import Chat from './Chat.vue'                     
import Stats from './Stats.astro'                  <!-- 静的カウンター = CSS -->

<Hero />                                          <!-- 静的、ハイドレーションなし -->
<Carousel client:visible />                       <!-- 表示されたときにハイドレート -->
<MobileMenu client:media="(max-width: 768px)" />  <!-- モバイルのみ -->
<Chat client:idle />                               <!-- ページが落ち着いた後に -->
<Stats />                                          <!-- 純粋なCSSアニメーション、JS不要 -->

画像最適化

自動最適化には astro:assets を使用します。

---
// src/pages/index.astro
import { Image } from 'astro:assets'
import heroImage from '../assets/images/hero.png'
---

<Image 
  src={heroImage} 
  alt="ヒーロー画像" 
  width={800} 
  height={600}
  loading="lazy"
  format="webp"
/>

CMSや外部ソースからの画像の場合:

---
import { Image } from 'astro:assets'
---

<Image 
  src="https://example.com/image.jpg" 
  alt="外部画像" 
  width={800}
  height={600}
/>

ルール:

  • CLS(Cumulative Layout Shift)防止のため、常に width と height を指定する
  • 画面外の画像には loading="lazy" を使用する
  • webp または avif 形式を優先する
  • ヒーロー画像は適切に最適化し、サイズ設定する

SEOパターン

---
// src/components/SEO.astro
export interface Props {
  title: string
  description: string
  image?: string
  article?: boolean
  publishedTime?: Date
  author?: string
  tags?: string[]
}

const { 
  title, 
  description, 
  image = '/og-default.png',
  article = false,
  publishedTime,
  author,
  tags = []
} = Astro.props

const canonicalURL = new URL(Astro.url.pathname, Astro.site)
const imageURL = new URL(image, Astro.site)
---

<!-- プライマリメタタグ -->
<title>{title}</title>
<meta name="title" content={title} />
<meta name="description" content={description} />
<link rel="canonical" href={canonicalURL} />

<!-- Open Graph -->
<meta property="og:type" content={article ? 'article' : 'website'} />
<meta property="og:url" content={canonicalURL} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={imageURL} />

<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content={new URL(Astro.site).hostname} />
<meta property="twitter:url" content={canonicalURL} />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:image" content={imageURL} />

<!-- 構造化データ -->
{article && publishedTime && (
  <script type="application/ld+json" set:html={JSON.stringify({
    "@context": "https://schema.org",
    "@type": "Article",
    "headline": title,
    "description": description,
    "image": imageURL.toString(),
    "datePublished": publishedTime.toISOString(),
    "dateModified": new Date().toISOString(),
    "author": {
      "@type": "Person",
      "name": author
    }
  })} />
)}

使用例:

---
// src/pages/index.astro
import BaseLayout from '../layouts/BaseLayout.astro'
import SEO from '../components/SEO.astro'
---

<BaseLayout>
  <SEO slot="head" title="Vera Sesiom - ソフトウェア開発" description="私たちは意味のあるソフトウェアを構築します。" />
  <!-- ページコンテンツ -->
</BaseLayout>

関連スキル