Skip to content

Commit 5baad8b

Browse files
committed
chore: init
1 parent 528c6fd commit 5baad8b

File tree

30 files changed

+224
-103
lines changed

30 files changed

+224
-103
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"fast-glob": "^3.3.2",
3030
"prettier-plugin-astro": "^0.13.0",
3131
"typescript": "^5.4.5",
32-
"unocss": "^0.59.4"
32+
"unocss": "^0.59.4",
33+
"vite": "^5.2.0"
3334
},
3435
"packageManager": "[email protected]+sha512.d1a029e1a447ad90bc96cd58b0fad486d2993d531856396f7babf2d83eb1823bb83c5a3d0fc18f675b2d10321d49eb161fece36fe8134aa5823ecd215feed392"
3536
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/tutorial/1-basics/1-introduction/1-welcome/_files/counter.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/content/tutorial/1-basics/1-introduction/1-welcome/_solution/counter.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/content/tutorial/1-basics/1-introduction/1-welcome/content.md

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
employees:
2+
- id: 1
3+
name: John Doe
4+
job: Developer
5+
skills:
6+
- JavaScript
7+
- Python
8+
- C++
9+
- id: 2
10+
name: Jane Doe
11+
job: Designer
12+
skills:
13+
- Photoshop
14+
- Illustrator
15+
- InDesign
16+
projects:
17+
- id: 101
18+
name: Project Alpha
19+
description: This is the first project.
20+
- id: 102
21+
name: Project Beta
22+
description: This is the second project.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const content = ["Initial content"];
2+
3+
export { content };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import content from "./content.yaml";
2+
3+
export { content };
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
type: lesson
3+
title: importing-yaml-files
4+
focus: /index.js
5+
---
6+
7+
# Welcome to Vite Plugin tutorial
8+
9+
Hey there, and welcome to Vite Plugin tutorial 👋!
10+
11+
In this tutorial we'll go through steps for creating custom Vite plugins. We'll start by creating a custom Vite plugin for loading `.yaml` files.
12+
13+
Our goal is to be able to import `content.yaml` file in the Javascript file and use it as plain Javascript object.
14+
15+
```js [index.js]
16+
import content from "./content.yaml";
17+
18+
console.log(content);
19+
// > [{ employees: [{ id: 1, ...}, ...], projects: { id: 101, ...}, ... }]
20+
```
21+
22+
Try doing this in `index.js`:
23+
24+
```js [index.js] add={1} del={2}
25+
import content from "./content.yaml";
26+
const content = ["Initial content"];
27+
28+
export { content };
29+
```
30+
31+
At this point we should run into error when Vite fails to load `.yaml` file.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import content from "./content.yaml";
2+
3+
export { content };

0 commit comments

Comments
 (0)