-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
335 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: bar | ||
--- | ||
|
||
Hello | ||
|
||
--- | ||
|
||
world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: foo | ||
--- | ||
|
||
Hello | ||
|
||
--- | ||
|
||
world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createContentLoader } from 'vitepress' | ||
|
||
export default createContentLoader('data-loading/content/*.md', { | ||
includeSrc: true, | ||
excerpt: true, | ||
render: true, | ||
transform(data) { | ||
return data.map((item) => ({ | ||
...item, | ||
transformed: true | ||
})) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Static Data | ||
|
||
<script setup lang="ts"> | ||
import { data } from './basic.data.js' | ||
import { data as contentData } from './contentLoader.data.js' | ||
</script> | ||
|
||
<pre id="basic">{{ data }}</pre> | ||
|
||
<pre id="content">{{ contentData }}</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
describe('static data file support in vite 3', () => { | ||
beforeAll(async () => { | ||
await goto('/data-loading/data') | ||
}) | ||
|
||
test('render correct content', async () => { | ||
expect(await page.textContent('pre#basic')).toMatchInlineSnapshot(` | ||
"[ | ||
{ | ||
\\"foo\\": true | ||
}, | ||
{ | ||
\\"bar\\": true | ||
} | ||
]" | ||
`) | ||
expect(await page.textContent('pre#content')).toMatchInlineSnapshot(` | ||
"[ | ||
{ | ||
\\"src\\": \\"---\\\\ntitle: bar\\\\n---\\\\n\\\\nHello\\\\n\\\\n---\\\\n\\\\nworld\\\\n\\", | ||
\\"html\\": \\"<p>Hello</p>\\\\n<hr>\\\\n<p>world</p>\\\\n\\", | ||
\\"frontmatter\\": { | ||
\\"title\\": \\"bar\\" | ||
}, | ||
\\"excerpt\\": \\"<p>Hello</p>\\\\n\\", | ||
\\"url\\": \\"/data-loading/content/bar.html\\", | ||
\\"transformed\\": true | ||
}, | ||
{ | ||
\\"src\\": \\"---\\\\ntitle: foo\\\\n---\\\\n\\\\nHello\\\\n\\\\n---\\\\n\\\\nworld\\\\n\\", | ||
\\"html\\": \\"<p>Hello</p>\\\\n<hr>\\\\n<p>world</p>\\\\n\\", | ||
\\"frontmatter\\": { | ||
\\"title\\": \\"foo\\" | ||
}, | ||
\\"excerpt\\": \\"<p>Hello</p>\\\\n\\", | ||
\\"url\\": \\"/data-loading/content/foo.html\\", | ||
\\"transformed\\": true | ||
} | ||
]" | ||
`) | ||
}) | ||
}) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.