Skip to content

Latest commit

 

History

History

README.md

Astral Basic Example

This is a minimal Astral site that exercises the current core features:

  • Markdown pages with MDEx frontmatter
  • plain HTML pages
  • HEEx-first .astral pages, layouts, and local components
  • default .astral and per-page EEx layouts
  • public static files
  • Volt-managed TypeScript and CSS
  • schema-validated posts in content/posts
  • dynamic collection detail pages with pages/blog/[slug].astral
  • setup-declared dynamic tag pages with pages/tags/[tag].astral
  • custom root 404 page written to dist/404.html
  • generated /feed.xml and /sitemap.xml routes
  • Astral's development server
  • Volt JS/TS formatting and linting

Run the dev server

mix deps.get
mix astral.dev

Open http://localhost:4000.

Try editing files in pages/, components/, content/posts/, layouts/, public/, or assets/ while the server is running.

The layout uses Astral.asset_path(@site, "app.ts"); it returns /assets/app.ts in dev and /assets/app.js for this example's static build. The example sets hash false in astral.config.exs so static builds emit dist/assets/app.js.

Check formatting and linting

This example follows Volt's formatting and linting setup:

  • .formatter.exs installs Volt.Formatter so mix format formats TypeScript too.
  • config/config.exs configures config :volt, :format and config :volt, :lint.
  • mix check runs mix format --check-formatted and mix volt.js.check --type-aware --type-check.
mix check

Build the static site

mix deps.get
mix astral.build

The output is written to dist/.

Routes

  • /
  • /about/
  • /blog/hello-astral/ from content/posts/hello-astral.md rendered by pages/blog/[slug].astral
  • /tags/astral/ generated from pages/tags/[tag].astral
  • /components/
  • /landing/
  • /raw/
  • /404/ served with 404 status in development and written to dist/404.html
  • /robots.txt
  • /feed.xml
  • /sitemap.xml