Astro Starter Kit: Basics
π Project Structure
The important files and folders to take note of are as follows:
/
βββ src/
β βββ components/
β β βββ MoviesList.tsx - Container for the movies displayed through the `WatchList` component
β β βββ Search.tsx - Display the search box and handles the search requests to OMDB API
β β βββ WatchButton.tsx - Renders the buttons titled 'Watched' and 'Want To Watch'
β β βββ WatchList.tsx - Renders the movies rendered in Top 10 Movies Watched/Want To Watch based on the button clicked
β β βββ SearchResult.tsx - Displays the movies returned from the OMDB API based on the query entered in the search box
β βββ layouts/
β β βββ Layout.astro - Contains the global styles and the overall structure of the index html page
β βββ pages/
β βββ index.astro - Contains the different React components embedded within it
βββ package.json - Description of the project with its associated higher level yarn dependencies
βββ astro.config.mjs - Configuration for Astro
βββ renovate.json - Schema for Renovate Bot (creates automated pull requests to update the yarn ependencies)
βββ tailwind.config.cjs - Configuration for Tailwind CSS
βββ tsconfig.json - Configuration for TypeScript
βββ yarn.lock - Dependency tree for Yarn
Astro looks for .astro
or .md
files in the src/pages/
directory. Each page is exposed as a route based on its file name.
There's nothing special about src/components/
, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
Any static assets, like images, can be placed in the public/
directory.
π§ Commands
All commands are run from the root of the project, from a terminal:
Command | Action |
---|---|
yarn |
Installs dependencies |
yarn dev |
Starts local dev server at localhost:3000 |
yarn build |
Build your production site to ./dist/ |
yarn preview |
Preview your build locally, before deploying |
yarn astro ... |
Run CLI commands like astro add , astro check |
yarn astro -- --help |
Get help using the Astro CLI |
π Want to learn more?
Feel free to check the Astro documentation or jump into the Discord server.