Skip to content

Astro

sh
npm create astro@latest

Directory Structure

.
|-- Makefile
|-- README.md
`-- astro
    |-- README.md
    |-- astro.config.mjs
    |-- package-lock.json
    |-- package.json
    |-- public
    |   `-- favicon.svg
    |-- src
    |   |-- components
    |   |   `-- Card.astro
    |   |-- env.d.ts
    |   |-- layouts
    |   |   `-- Layout.astro
    |   `-- pages
    |       `-- index.astro
    `-- tsconfig.json
sh
cd astro && npm run dev

Accesse Browser

http://localhost:4321/

File based routing

 Astroは、/src/pages/ディレクトリ内の対応するファイルをページとして扱う。ファイルのパス名を使って自動的にページルートを構築。

|-- src
    `-- pages
        |-- index.astro
        `-- posts
            `-- sample.*
http://localhost:4321/posts/sample