.astro files
Front Matter
Available on build. Server side stuff before
build
process
---
---
Ex 1: Front Matter data
---
const clientName = 'Polytechnic Pals'
---
{clientName}
Ex 2: Get the Year
---
const theYear = new Date();
---
{theYear..getFullYear()}
Ex 3: Objects
---
const user = {
name : 'Victor E. Eagle',
age : 100,
}
---
{user.name}
{user.age}
Ex 4: Map Over Data
---
const emojiSet = ['π', 'π', 'π', 'π'];
---
{ emojiSet.map( emoji => <p> {emoji} </p> ) }
Ex 5: External JSON Data
---
import data from "../data/theData.json"
---
{data.PROPERTY}
Ex 6: API Data
---
const response = await fetch('https://jsonplaceholder.typicode.com/posts');
const data = await response.json();
//check check
console.log(data);
---
{data.PROPERTY}
Last updated