Skip to content

Commit

Permalink
refactor: use @nuxt/ui for examples (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
arashsheyda authored Dec 13, 2023
1 parent af43e51 commit 9f3d7cf
Show file tree
Hide file tree
Showing 269 changed files with 1,756 additions and 1,800 deletions.
2 changes: 1 addition & 1 deletion .docs/0.hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description: 'A minimal Nuxt 3 application only requires the `app.vue` and `nuxt

:read-more{to="/docs/getting-started/introduction"}

:sandbox{repo="nuxt/examples" branch="main" dir="hello-world" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/hello-world" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/1.features/1.auto-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Example of the auto-imports feature in Nuxt with:
:read-more{to="/docs/guide/directory-structure/composables"}
:read-more{to="/docs/guide/directory-structure/utils"}

:sandbox{repo="nuxt/examples" branch="main" dir="features/auto-imports" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/features/auto-imports" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/1.features/2.data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ description: 'This example demonstrates data fetching with Nuxt 3 using built-in
:read-more{to="/docs/getting-started/data-fetching"}
:read-more{to="/docs/guide/directory-structure/server"}

:sandbox{repo="nuxt/examples" branch="main" dir="features/data-fetching" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/features/data-fetching" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/1.features/3.state-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ description: 'This example shows how to use the `useState` composable to create
:read-more{to="/docs/getting-started/state-management"}
:read-more{to="/docs/api/composables/use-state"}

:sandbox{repo="nuxt/examples" branch="main" dir="features/state-management" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/features/state-management" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/1.features/4.meta-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description: 'This example shows how to use the Nuxt helpers and composables for

:read-more{to="/docs/getting-started/seo-meta"}

:sandbox{repo="nuxt/examples" branch="main" dir="features/meta-tags/" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/features/meta-tags/" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/1.features/5.layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ description: 'This example shows how to define default and custom layouts.'
:read-more{to="/docs/getting-started/views#layouts"}
:read-more{to="/docs/guide/directory-structure/layouts"}

:sandbox{repo="nuxt/examples" branch="main" dir="features/layouts" file="pages/index.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/features/layouts" file="pages/index.vue"}
2 changes: 1 addition & 1 deletion .docs/2.routing/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description: 'This example shows how to add route middleware with the middleware

:read-more{to="/docs/guide/directory-structure/middleware"}

:sandbox{repo="nuxt/examples" branch="main" dir="routing/middleware" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/routing/middleware" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/2.routing/pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description: 'This example shows how to use the pages/ directory to create appli

:read-more{to="/docs/guide/directory-structure/pages"}

:sandbox{repo="nuxt/examples" branch="main" dir="routing/pages" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/routing/pages" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/2.routing/universal-router.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ title: 'Universal Router'
description: 'This example demonstrates Nuxt universal routing utilities without depending on `pages/` and `vue-router`.'
---

:sandbox{repo="nuxt/examples" branch="main" dir="routing/universal-router" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/routing/universal-router" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/4.advanced/config-extends.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ This example shows how to use the `extends` key in `nuxt.config.ts` to use the `

:read-more{to="/docs/getting-started/layers"}

:sandbox{repo="nuxt/examples" branch="main" dir="advanced/config-extends" file="nuxt.config.ts"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/advanced/config-extends" file="nuxt.config.ts"}
2 changes: 1 addition & 1 deletion .docs/4.advanced/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description: 'This example shows how to handle errors in different contexts: pag

:read-more{to="/docs/getting-started/error-handling"}

:sandbox{repo="nuxt/examples" branch="main" dir="advanced/error-handling" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/advanced/error-handling" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/4.advanced/jsx.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description: 'This example shows how to use JSX syntax with typescript in Nuxt p

:read-more{icon="i-simple-icons-vuedotjs" to="https://vuejs.org/guide/extras/render-function.html#jsx-tsx" target="_blank"}

:sandbox{repo="nuxt/examples" branch="main" dir="advanced/jsx" file="nuxt.config.ts"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/advanced/jsx" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/4.advanced/locale.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ description: "This example shows how to define a locale composable to handle the
You can right-click to "View Page Source" and see that Nuxt renders the correct date in SSR based on the visitor's locale.
::

:sandbox{repo="nuxt/examples" branch="main" dir="advanced/locale" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/advanced/locale" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/4.advanced/module-extend-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description: 'This example defines a new `test` page using `extendPages` within

:read-more{to="/docs/guide/going-further/modules"}

:read-more{repo="nuxt/examples" branch="main" dir="advanced/module-extend-pages" file="pages/index.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/advanced/module-extend-pages" file="pages/index.vue"}
2 changes: 1 addition & 1 deletion .docs/4.advanced/teleport.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ This example shows how to use the `<Teleport>` with client-side and server-side

:read-more{to="/docs/api/components/teleports"}

:sandbox{repo="nuxt/examples" branch="main" dir="advanced/teleport" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/advanced/teleport" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/4.advanced/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description: 'This example shows how to test your Nuxt application.'

:read-more{to="/docs/getting-started/testing"}

:sandbox{repo="nuxt/examples" branch="main" dir="advanced/testing" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/advanced/testing" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/4.advanced/use-cookie.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description: 'This example shows how to use the useCookie API to persist small a

:read-more{to="/docs/api/composables/use-cookie"}

:sandbox{repo="nuxt/examples" branch="main" dir="advanced/use-cookie" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/advanced/use-cookie" file="app.vue"}
2 changes: 1 addition & 1 deletion .docs/4.advanced/use-custom-fetch-composable.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ title: 'Use Custom Fetch Composable'
description: 'This example shows a convenient wrapper for the useFetch composable from nuxt. It allows you to customize the fetch request with default values and user authentication token.'
---

:sandbox{repo="nuxt/examples" branch="main" dir="advanced/use-custom-fetch-composable" file="composables/useCustomFetch.ts"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/advanced/use-custom-fetch-composable" file="composables/useCustomFetch.ts"}
2 changes: 1 addition & 1 deletion .docs/7.experimental/wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ title: 'WASM'
description: 'This example demonstrates the server-side support of WebAssembly in Nuxt 3.'
---

:sandbox{repo="nuxt/examples" branch="main" dir="experimental/wasm" file="app.vue"}
:sandbox{repo="nuxt/examples" branch="main" dir="examples/experimental/wasm" file="app.vue"}
9 changes: 4 additions & 5 deletions .scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import { join, resolve } from 'pathe'
const stringify = contents => JSON.stringify(contents, null, 2)

const packages = await globby([
'**/package.json',
'examples/**/package.json',
'!**/node_modules',
'!**/.nitro',
'!**/.vercel',
'!**/.output',
'!package.json',
]).then(r => r.sort())
const names = new Set()

Expand Down Expand Up @@ -56,7 +55,7 @@ export default function middleware(req) {
const forced = req.url.match(/\\?force=(.*)$/)?.[1]
const hostname = req.headers.get('host')
const subdomain = forced || req.headers.get('cookie')?.match(/forced=([^;]*)(;|$)/)?.[1] || hostname.split('.').shift()
if (names.includes(subdomain)) {
const response = new Response()
const url = new URL(req.url)
Expand All @@ -66,14 +65,14 @@ export default function middleware(req) {
}
return response
}
return new Response(null, {
status: 307,
headers: {
Location: 'https://nuxt.com/docs/examples/essentials/hello-world/'
}
})
}`
)
await fsp.writeFile(
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

## Sites

- [hello-world](https://hello-world.example.nuxt.space/) - ([source](./hello-world/))
- [hello-world](https://hello-world.example.nuxt.space/) - ([source](./examples/hello-world/))

### Features

Inside [features/](./features).
Inside [features/](./examples/features).

- [auto-imports](https://auto-imports.example.nuxt.space/)
- [data-fetching](https://data-fetching.example.nuxt.space/)
Expand All @@ -20,15 +20,15 @@ Inside [features/](./features).

### Routing

Inside [routing/](./routing).
Inside [routing/](./examples/routing).

- [middleware](https://middleware.example.nuxt.space/)
- [pages](https://pages.example.nuxt.space/)
- [universal-router](https://universal-router.example.nuxt.space/)

### UI Frameworks

Inside [ui/](./ui).
Inside [ui/](./examples/ui).

- [daisyui](https://daisyui.example.nuxt.space/)
- [tailwindcss](https://tailwindcss.example.nuxt.space/)
Expand All @@ -37,13 +37,13 @@ Inside [ui/](./ui).

### Authentication

Inside [auth/](./auth).
Inside [auth/](./examples/auth).

- [local](https://local-auth.example.nuxt.space/)

## Advanced

Inside [advanced/](./advanced).
Inside [advanced/](./examples/advanced).

- [config-extends](https://config-extends.example.nuxt.space/)
- [error-handling](https://error-handling.example.nuxt.space/)
Expand All @@ -57,6 +57,6 @@ Inside [advanced/](./advanced).

## Experimental

Inside [experimental/](./experimental).
Inside [experimental/](./examples/experimental).

- [wasm](https://wasm.example.nuxt.space/)
48 changes: 0 additions & 48 deletions advanced/error-handling/app.vue

This file was deleted.

29 changes: 0 additions & 29 deletions advanced/error-handling/error.vue

This file was deleted.

5 changes: 0 additions & 5 deletions advanced/error-handling/nuxt.config.ts

This file was deleted.

3 changes: 0 additions & 3 deletions advanced/error-handling/pages/index.vue

This file was deleted.

3 changes: 0 additions & 3 deletions advanced/error-handling/pages/other.vue

This file was deleted.

5 changes: 0 additions & 5 deletions advanced/jsx/nuxt.config.ts

This file was deleted.

24 changes: 0 additions & 24 deletions advanced/locale/app.vue

This file was deleted.

5 changes: 0 additions & 5 deletions advanced/locale/nuxt.config.ts

This file was deleted.

5 changes: 0 additions & 5 deletions advanced/module-extend-pages/layouts/default.vue

This file was deleted.

22 changes: 0 additions & 22 deletions advanced/teleport/app.vue

This file was deleted.

Loading