コンテンツにスキップ
このページの翻訳は LLM によって生成されています。誤りに気づいた場合は GitHub で issue を開いてお知らせください。

ページとレイアウト

varshaはファイルベースのルーティングを使用しており、src/pages/にファイルを置くだけでページを作成できます。このガイドでは、ページの作成、レイアウトの使用、共通コンポーネントの構成方法について説明します。

基本的なマーケティングページ

Section titled “基本的なマーケティングページ”

マーケティングページ(ランディングページ、About、Pricingなど)はすべてMarketingLayoutを使用する必要があります:

src/pages/about.astro
---
import MarketingLayout from '../components/MarketingLayout.astro';
---
<MarketingLayout
title="About Us"
description="Learn about our company."
canonicalPath="/about/"
>
<main class="page">
<section class="hero">
<h1>About Us</h1>
<p>We build tools that help people ship faster.</p>
</section>
</main>
</MarketingLayout>
プロパティ型必須説明
titlestringはいページタイトル(<title>タグとOGタグに使用)
descriptionstringはいメタディスクリプション
canonicalPathstringはい正規URLパス(/about/のように)
imagestringいいえOG画像のパス(デフォルトは/og-image.png)

ヒーローセクションのあるページを作成:

src/pages/features.astro
---
import MarketingLayout from '../components/MarketingLayout.astro';
---
<MarketingLayout
title="Features"
description="Everything varsha has to offer."
canonicalPath="/features/"
>
<main class="page">
<section class="hero">
<h1>Everything you need to ship.</h1>
<p>Built-in components, themes, and tools.</p>
<div class="hero-actions">
<a href="/docs/quick-start/" class="btn btn-primary">Get started</a>
<a href="#features" class="btn btn-secondary">See features</a>
</div>
</section>
<section id="features" class="section">
<div class="container">
<h2>Features</h2>
<div class="card-grid">
<div class="card">
<h3>Beautiful by default</h3>
<p>18+ themes and a polished design system.</p>
</div>
<div class="card">
<h3>Fast by default</h3>
<p>Astro ships zero JavaScript by default.</p>
</div>
</div>
</div>
</section>
</main>
</MarketingLayout>

varshaはマーケティングページに一貫したセクション構造を使用しています:

<main class="page">
<section class="hero"> <!-- ページヘッダー/ヒーロー -->
<section class="section"> <!-- コンテンツセクション -->
<div class="container"> <!-- コンテンツ幅を制限 -->
<section class="section alt"> <!-- 代替背景のセクション -->
</main>

使用可能なユーティリティクラス

Section titled “使用可能なユーティリティクラス”
クラス目的
.pageメインページラッパー
.heroフルワイドのヒーローセクション
.section標準パディング付きコンテンツセクション
.section.alt代替背景のセクション
.container最大幅のコンテナ(デフォルトで中央揃え)
.card-gridレスポンシブなカードグリッド
.card個々のカード
.btn / .btn-primary / .btn-secondaryボタンスタイル

「Built with varsha by myndlabs」の帰属バッジを表示します。このコンポーネントはMarketingLayoutによって自動的に含まれます。削除しないでください — これはvarshaの使用条件において必要な帰属表示です。

import BuiltWith from '../components/BuiltWith.astro';
<BuiltWith />

カスタムセクションコンポーネント

Section titled “カスタムセクションコンポーネント”

再利用可能なセクションコンポーネントをsrc/components/に作成できます:

src/components/FeatureGrid.astro
---
const { features } = Astro.props;
---
<div class="card-grid">
{features.map(feature => (
<div class="card">
<h3>{feature.title}</h3>
<p>{feature.description}</p>
</div>
))}
</div>

そして任意のページで使用:

---
import MarketingLayout from '../components/MarketingLayout.astro';
import FeatureGrid from '../components/FeatureGrid.astro';
const features = [
{ title: 'Fast', description: 'Zero JS by default.' },
{ title: 'Beautiful', description: '18+ built-in themes.' },
];
---
<MarketingLayout title="Features" description="..." canonicalPath="/features/">
<main class="page">
<section class="hero">
<h1>Features</h1>
</section>
<section class="section">
<div class="container">
<FeatureGrid features={features} />
</div>
</section>
</main>
</MarketingLayout>

新しいページを追加した後、MarketingLayout.astroのナビゲーションリンクを更新します:

src/components/MarketingLayout.astro
<div class="nav-links">
<a href="/">Home</a>
<a href="/features/">Features</a>
<a href="/pricing/">Pricing</a>
<a href="/docs/">Docs</a>
</div>

デスクトップナビゲーション(.nav-links)とモバイルナビゲーションパネル(.nav-menu-panel)の両方を更新して、一貫性を保ってください。

カスタム404ページはsrc/pages/404.astroにあります。ブランドに合わせて自由にカスタマイズできますが、ユーザーをホームに戻すためのクリアなナビゲーションを維持してください。

  1. 常にMarketingLayoutを使用する — マーケティングページにはヘッダー、フッター、テーマ、帰属表示の一貫性のため
  2. 意味的なHTMLを使用する — <main>、<section>、<h1>-<h3>、<nav>、<footer>
  3. コンテンツをコンテナ内に保つ — コンテンツが広すぎる画面で読みにくくならないよう、.containerを使用
  4. 一貫したセクション構造を使用する — .hero → .section → .section.altなど
  5. コンポーネントは再利用可能に保つ — 繰り返しパターンをsrc/components/に抽出
  6. 帰属表示を維持する — BuiltWithコンポーネントは削除しないでください

カスタマイズ

ブランドに合わせてカラー、タイポグラフィ、メタデータを変更します。

カスタマイズ →

コンポーネントリファレンス

ビルトインコンポーネントの完全なリストを参照します。

コンポーネント →