mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
docs: add Stackblitz links for examples (#2559)
This commit is contained in:
parent
d45869d6ce
commit
59e5cfea39
17
examples/README.md
Normal file
17
examples/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Nuxt 3 Examples
|
||||
|
||||
| Example | Source | Playground |
|
||||
|---|---|---|
|
||||
| `hello-world` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/hello-world) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/hello-world?file=app.vue&terminal=dev) |
|
||||
| `locale` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/locale) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/locale?file=app.vue&terminal=dev) |
|
||||
| `module-extend-pages` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/module-extend-pages) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/module-extend-pages?file=app.vue&terminal=dev) |
|
||||
| `use-async-data` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/use-async-data) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/use-async-data?file=app.vue&terminal=dev) |
|
||||
| `use-cookie` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/use-cookie) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/use-cookie?file=app.vue&terminal=dev) |
|
||||
| `use-fetch` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/use-fetch) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/use-fetch?file=app.vue&terminal=dev) |
|
||||
| `use-meta` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/use-meta) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/use-meta?file=app.vue&terminal=dev) |
|
||||
| `use-state` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/use-state) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/use-state?file=app.vue&terminal=dev) |
|
||||
| `with-components` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-components) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-components?file=app.vue&terminal=dev) |
|
||||
| `with-composables` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-composables) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-composables?file=app.vue&terminal=dev) |
|
||||
| `with-layouts` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-layouts) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-layouts?file=app.vue&terminal=dev) |
|
||||
| `with-pages` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-pages) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-pages?file=app.vue&terminal=dev) |
|
||||
| `with-wasm` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-wasm) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-wasm?file=app.vue&terminal=dev) |
|
31
scripts/update-examples.ts
Normal file
31
scripts/update-examples.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { fileURLToPath } from 'url'
|
||||
import { promises as fs } from 'fs'
|
||||
import { resolve } from 'pathe'
|
||||
|
||||
async function run () {
|
||||
const examplesRoot = resolve(fileURLToPath(import.meta.url), '../../examples')
|
||||
|
||||
const examples = await fs.readdir(examplesRoot)
|
||||
|
||||
const data = await Promise.all(examples.map(async (name) => {
|
||||
const path = resolve(examplesRoot, name)
|
||||
if ((await fs.lstat(path)).isFile()) {
|
||||
return
|
||||
}
|
||||
|
||||
const github = `https://github.com/nuxt/framework/tree/main/examples/${name}`
|
||||
const stackblitz = `https://stackblitz.com/github/nuxt/framework/tree/main/examples/${name}?file=app.vue&terminal=dev`
|
||||
return {
|
||||
name,
|
||||
path,
|
||||
github,
|
||||
stackblitz
|
||||
}
|
||||
}))
|
||||
|
||||
const table = '| Example | Source | Playground |\n|---|---|---|\n' + data.filter(Boolean).map(i => `| \`${i.name}\` | [GitHub](${i.github}) | [Play Online](${i.stackblitz}) |`).join('\n')
|
||||
|
||||
await fs.writeFile(resolve(examplesRoot, 'README.md'), `# Nuxt 3 Examples\n\n${table}\n`, 'utf-8')
|
||||
}
|
||||
|
||||
run()
|
Loading…
Reference in New Issue
Block a user