hello world ใน astro
#astro28 ก.ย. 2567
hello world ใน astro
เรามาดู hello world ใน astro กันครับ ก่อนอื่นก็เตรียมสิ่งที่ต้องใช้ก่อน ตามด้านล่างนี้
Prerequisites
- Node.js - v18.17.1 or v20.3.0 or higher. ( v19 is not supported.)
- Text editor - We recommend VS Code with our Official Astro extension.
- Terminal - Astro is accessed through its command-line interface (CLI).
สร้างโปรเจ็คจาก CLI wizard
ต่อไปเราไปสร้างโปรเจ็คกันครับ ใช้คำสั่งด้านล่างเลย
npm create astro@latest
ตอนติดตั้ง เราสามารถใช้ template ได้ด้วย ดังตัวอย่างคำสั่ง
npm create astro@latest -- --template <example-name>
npm create astro@latest -- --template <github-username>/<github-repo>
start project
เมื่อติดตั้งได้แล้ว ต่อไปเราก็ลอง start โปรเจ็คขึ้นมากันครับ ตามคำสั่งด้านล่าง
npm run dev
แค่นี้เราก็ได้แล้ว ต่อไปเราไปดูคำสั่ง build กัน ตามด้านล่าง
npm run build
แหล่งอ้างอิง https://docs.astro.build/en/install-and-setup/