One of the things we are conditioned to do as front-end developers is to prefer JSON data, because it’s used everywhere.
But if you’re creating your own data sets inside Astro, I would recommend using JavaScript over JSON for a very simple reason.
- You can use comments in JavaScript.
- But you cannot use comments in JSON.
So it’s much easier to create a dataset with JavaScript.
export default { // Your data here...}You can import it just like a JSON file.
import data from '@/content/data.js'This is generally much easier even though it’s not a commonly written practice.
Welcome! Unfortunately, you don’t have access to this lesson. To get access, please purchase the course or enroll in Magical Dev School.
Unlock this lesson