feat: add with-content playground
This commit is contained in:
parent
813fd1e557
commit
87e50921ad
16 changed files with 186 additions and 1 deletions
20
examples/with-content/.gitignore
vendored
Normal file
20
examples/with-content/.gitignore
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
# build output
|
||||
dist/
|
||||
.astro/
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
4
examples/with-content/.vscode/extensions.json
vendored
Normal file
4
examples/with-content/.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"recommendations": ["astro-build.astro-vscode"],
|
||||
"unwantedRecommendations": []
|
||||
}
|
11
examples/with-content/.vscode/launch.json
vendored
Normal file
11
examples/with-content/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "./node_modules/.bin/astro dev",
|
||||
"name": "Development server",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
45
examples/with-content/README.md
Normal file
45
examples/with-content/README.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Astro Starter Kit: Minimal
|
||||
|
||||
```
|
||||
npm create astro@latest -- --template minimal
|
||||
```
|
||||
|
||||
[](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal)
|
||||
|
||||
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
|
||||
|
||||
## 🚀 Project Structure
|
||||
|
||||
Inside of your Astro project, you'll see the following folders and files:
|
||||
|
||||
```
|
||||
/
|
||||
├── public/
|
||||
├── src/
|
||||
│ └── pages/
|
||||
│ └── index.astro
|
||||
└── package.json
|
||||
```
|
||||
|
||||
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
|
||||
|
||||
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
|
||||
|
||||
Any static assets, like images, can be placed in the `public/` directory.
|
||||
|
||||
## 🧞 Commands
|
||||
|
||||
All commands are run from the root of the project, from a terminal:
|
||||
|
||||
| Command | Action |
|
||||
| :--------------------- | :----------------------------------------------- |
|
||||
| `npm install` | Installs dependencies |
|
||||
| `npm run dev` | Starts local dev server at `localhost:3000` |
|
||||
| `npm run build` | Build your production site to `./dist/` |
|
||||
| `npm run preview` | Preview your build locally, before deploying |
|
||||
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
||||
| `npm run astro --help` | Get help using the Astro CLI |
|
||||
|
||||
## 👀 Want to learn more?
|
||||
|
||||
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
|
4
examples/with-content/astro.config.mjs
Normal file
4
examples/with-content/astro.config.mjs
Normal file
|
@ -0,0 +1,4 @@
|
|||
import { defineConfig } from 'astro/config';
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({});
|
19
examples/with-content/package.json
Normal file
19
examples/with-content/package.json
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "@example/with-content",
|
||||
"type": "module",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"start": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"astro": "astro"
|
||||
},
|
||||
"dependencies": {
|
||||
"astro": "^1.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"zod": "^3.17.3"
|
||||
}
|
||||
}
|
13
examples/with-content/public/favicon.svg
Normal file
13
examples/with-content/public/favicon.svg
Normal file
|
@ -0,0 +1,13 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 36 36">
|
||||
<path fill="#000" d="M22.25 4h-8.5a1 1 0 0 0-.96.73l-5.54 19.4a.5.5 0 0 0 .62.62l5.05-1.44a2 2 0 0 0 1.38-1.4l3.22-11.66a.5.5 0 0 1 .96 0l3.22 11.67a2 2 0 0 0 1.38 1.39l5.05 1.44a.5.5 0 0 0 .62-.62l-5.54-19.4a1 1 0 0 0-.96-.73Z"/>
|
||||
<path fill="url(#gradient)" d="M18 28a7.63 7.63 0 0 1-5-2c-1.4 2.1-.35 4.35.6 5.55.14.17.41.07.47-.15.44-1.8 2.93-1.22 2.93.6 0 2.28.87 3.4 1.72 3.81.34.16.59-.2.49-.56-.31-1.05-.29-2.46 1.29-3.25 3-1.5 3.17-4.83 2.5-6-.67.67-2.6 2-5 2Z"/>
|
||||
<defs>
|
||||
<linearGradient id="gradient" x1="16" x2="16" y1="32" y2="24" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#000"/>
|
||||
<stop offset="1" stop-color="#000" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<style>
|
||||
@media (prefers-color-scheme:dark){:root{filter:invert(100%)}}
|
||||
</style>
|
||||
</svg>
|
After Width: | Height: | Size: 873 B |
11
examples/with-content/sandbox.config.json
Normal file
11
examples/with-content/sandbox.config.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"infiniteLoopProtection": true,
|
||||
"hardReloadOnChange": false,
|
||||
"view": "browser",
|
||||
"template": "node",
|
||||
"container": {
|
||||
"port": 3000,
|
||||
"startScript": "start",
|
||||
"node": "14"
|
||||
}
|
||||
}
|
3
examples/with-content/src/content/blog/first.md
Normal file
3
examples/with-content/src/content/blog/first.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
title: 'Howdy'
|
||||
---
|
3
examples/with-content/src/content/blog/nested/entry.md
Normal file
3
examples/with-content/src/content/blog/nested/entry.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
title: Nested!
|
||||
---
|
3
examples/with-content/src/content/blog/second.md
Normal file
3
examples/with-content/src/content/blog/second.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
title: 'Hey!'
|
||||
---
|
5
examples/with-content/src/content/blog/~schema.ts
Normal file
5
examples/with-content/src/content/blog/~schema.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
export const schema = z.object({
|
||||
title: z.string(),
|
||||
});
|
1
examples/with-content/src/env.d.ts
vendored
Normal file
1
examples/with-content/src/env.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/// <reference types="astro/client" />
|
25
examples/with-content/src/pages/index.astro
Normal file
25
examples/with-content/src/pages/index.astro
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
import { fetchContent, fetchContentByEntry } from '.astro';
|
||||
|
||||
const blog = await fetchContent('blog');
|
||||
|
||||
const nestedEntry = await fetchContentByEntry('blog', 'nested/entry.md');
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>Astro</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{nestedEntry.id} {nestedEntry.data.title}</h1>
|
||||
{blog.map((entry) => (
|
||||
<p>
|
||||
{entry.slug} - {entry.data.title}
|
||||
</p>
|
||||
))}
|
||||
</body>
|
||||
</html>
|
10
examples/with-content/tsconfig.json
Normal file
10
examples/with-content/tsconfig.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/base",
|
||||
"compilerOptions": {
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
".astro": [".astro/content-generated"]
|
||||
}
|
||||
}
|
||||
}
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
@ -283,6 +283,15 @@ importers:
|
|||
unocss: 0.15.6
|
||||
vite-imagetools: 4.0.11
|
||||
|
||||
examples/with-content:
|
||||
specifiers:
|
||||
astro: ^1.5.2
|
||||
zod: ^3.17.3
|
||||
dependencies:
|
||||
astro: link:../../packages/astro
|
||||
devDependencies:
|
||||
zod: 3.19.1
|
||||
|
||||
examples/with-markdown-plugins:
|
||||
specifiers:
|
||||
'@astrojs/markdown-remark': ^1.1.3
|
||||
|
@ -18802,7 +18811,6 @@ packages:
|
|||
|
||||
/zod/3.19.1:
|
||||
resolution: {integrity: sha512-LYjZsEDhCdYET9ikFu6dVPGp2YH9DegXjdJToSzD9rO6fy4qiRYFoyEYwps88OseJlPyl2NOe2iJuhEhL7IpEA==}
|
||||
dev: false
|
||||
|
||||
/zwitch/2.0.3:
|
||||
resolution: {integrity: sha512-dn/sDAIuRCsXGnBD4P+SA6nv7Y54HQZjC4SPL8PToU3714zu7wSEc1129D/i0+vvjRfOlFo4Zqrpwj+Zhcykhw==}
|
||||
|
|
Loading…
Add table
Reference in a new issue