mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
chore(example): use @nuxt/ui
for examples (#2325)
Co-authored-by: Daniel Roe <daniel@roe.dev> Co-authored-by: Pooya Parsa <pyapar@gmail.com>
This commit is contained in:
parent
79a1b31e83
commit
afcaaff57d
@ -74,7 +74,7 @@ Nuxt 3 introduced the new Nuxt CLI command [`nuxi`](/getting-started/commands/).
|
|||||||
- "build": "nuxt build",
|
- "build": "nuxt build",
|
||||||
+ "build": "nuxi build",
|
+ "build": "nuxi build",
|
||||||
- "start": "nuxt start",
|
- "start": "nuxt start",
|
||||||
+ "start": "node .output/server/index.mjs"
|
+ "start": "nuxi preview"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -99,7 +99,7 @@ For all other situations, you can use the `nuxi build` command.
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"start": "nuxi preview"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
|
<script setup>
|
||||||
|
const version = 2 + 1
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="hello">
|
||||||
Hello Nuxt!
|
Hello Nuxt {{ version }}!
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.hello {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
font-size: 3rem;
|
||||||
|
padding: 10rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "example-hello-world",
|
"name": "example-hello-world",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"build": "nuxi build",
|
||||||
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nuxt3": "latest"
|
"nuxt3": "latest"
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
|
||||||
"start": "node .output/server/index.mjs"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,30 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
|
// see ../compoables/locale.ts for the implementation
|
||||||
const locales = useLocales()
|
const locales = useLocales()
|
||||||
const locale = useLocale()
|
const locale = useLocale()
|
||||||
const date = useLocaleDate(new Date('2016-10-26') /* NUXT_BIRTHDAY */)
|
const date = useLocaleDate(new Date('2016-10-26') /* NUXT_BIRTHDAY */)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<NuxtExampleLayout :show-tips="true" example="locale">
|
||||||
<h2>Nuxt birthday: {{ date }}</h2>
|
<h1 class="text-xl opacity-50">
|
||||||
<label for="locale-chooser">Locale: </label>
|
Nuxt birthday
|
||||||
<select id="locale-chooser" v-model="locale">
|
</h1>
|
||||||
|
<p class="text-4xl">
|
||||||
|
{{ date }}
|
||||||
|
</p>
|
||||||
|
<div class="mt-4" />
|
||||||
|
<label for="locale-chooser">Preview a different locale</label>
|
||||||
|
<select id="locale-chooser" v-model="locale" class="m-auto w-50 border n-border-base rounded p-1">
|
||||||
<option v-for="l of locales" :key="l" :value="l">
|
<option v-for="l of locales" :key="l" :value="l">
|
||||||
{{ l }}
|
{{ l }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<template #tips>
|
||||||
|
<div>
|
||||||
|
You can right click to "View Page Source" and see that Nuxt renders the correct date in SSR based on visitor's locale.
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
</NuxtExampleLayout>
|
||||||
|
</template>
|
||||||
|
@ -26,6 +26,7 @@ export const useLocales = () => {
|
|||||||
'en-US',
|
'en-US',
|
||||||
'en-GB',
|
'en-GB',
|
||||||
'ko-KR',
|
'ko-KR',
|
||||||
|
'zh-CN',
|
||||||
'ar-EG',
|
'ar-EG',
|
||||||
'fa-IR',
|
'fa-IR',
|
||||||
'ja-JP-u-ca-japanese'
|
'ja-JP-u-ca-japanese'
|
||||||
@ -38,6 +39,6 @@ export const useLocales = () => {
|
|||||||
|
|
||||||
// Using Intl.DateTimeFormat for language-sensitive date and time formatting
|
// Using Intl.DateTimeFormat for language-sensitive date and time formatting
|
||||||
// Learn more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
|
// Learn more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
|
||||||
export const useLocaleDate = (date: Ref<Date>, locale = useLocale()) => {
|
export const useLocaleDate = (date: Ref<Date> | Date, locale = useLocale()) => {
|
||||||
return computed(() => new Intl.DateTimeFormat(locale.value).format(date.value))
|
return computed(() => new Intl.DateTimeFormat(locale.value, { dateStyle: 'full' }).format(unref(date)))
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-locale",
|
"name": "example-locale",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
examples/module-extend-pages/layouts/default.vue
Normal file
5
examples/module-extend-pages/layouts/default.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<NuxtExampleLayout example="module-extend-pages">
|
||||||
|
<slot />
|
||||||
|
</NuxtExampleLayout>
|
||||||
|
</template>
|
@ -1,7 +1,8 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
buildModules: [
|
modules: [
|
||||||
'~/modules/pages'
|
'~/modules/pages',
|
||||||
|
'@nuxt/ui'
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-module-extend-pages",
|
"name": "example-module-extend-pages",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,24 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
{{ data }}
|
|
||||||
<button :disabled="pending" @click="refresh">
|
|
||||||
Refresh Data
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
const { data, refresh, pending } = await useAsyncData('/api/hello', () => $fetch('/api/hello'))
|
const { data, refresh, pending } = await useAsyncData('/api/hello', () => $fetch('/api/hello'))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NuxtExampleLayout example="use-async-data" show-tips="true">
|
||||||
|
<div>{{ data }}</div>
|
||||||
|
<div>
|
||||||
|
<NButton :disabled="pending" @click="refresh">
|
||||||
|
Refresh Data
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
<template #tips>
|
||||||
|
<div>
|
||||||
|
Nuxt will automatically read files in the
|
||||||
|
<a href="https://v3.nuxtjs.org/docs/directory-structure/server#api-routes" target="_blank">
|
||||||
|
<code>~/server/api</code> directory
|
||||||
|
</a>
|
||||||
|
to create API endpoints. Learn more about
|
||||||
|
<a href="https://v3.nuxtjs.org/docs/usage/data-fetching" target="_blank">data fetching</a>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NuxtExampleLayout>
|
||||||
|
</template>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
// vite: true
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-use-async-data",
|
"name": "example-use-async-data",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,59 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
const user = useCookie('user')
|
const user = useCookie<{ name: string }>('user')
|
||||||
const logins = useCookie('logins')
|
const logins = useCookie<number>('logins')
|
||||||
|
|
||||||
|
const name = ref('')
|
||||||
|
const interacted = ref(false)
|
||||||
|
|
||||||
const login = () => {
|
const login = () => {
|
||||||
logins.value = (logins.value || 0) + 1
|
logins.value = (logins.value || 0) + 1
|
||||||
user.value = { name: 'CookieLover.' + new Date().getMilliseconds() }
|
user.value = { name: name.value }
|
||||||
|
interacted.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
user.value = null
|
user.value = null
|
||||||
|
interacted.value = true
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="user">
|
<NuxtExampleLayout :show-tips="interacted" class="h-50" example="use-cookie">
|
||||||
<h1>Welcome {{ user.name }}</h1>
|
<template v-if="user">
|
||||||
<button @click="logout">
|
<h1 class="text-3xl mb-3">
|
||||||
Logout
|
Welcome, {{ user.name }}! 👋
|
||||||
</button>
|
</h1>
|
||||||
<hr>
|
<div>
|
||||||
You have logged in {{ logins }} times!
|
<NTip n="green6" icon="carbon:idea" class="inline-flex">
|
||||||
|
You have logged in <b>{{ logins }} times</b>!
|
||||||
|
</NTip>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div class="mt-3">
|
||||||
Click here to login:
|
<NButton n="red" icon="carbon:logout" @click="logout">
|
||||||
<button @click="login">
|
Log out
|
||||||
Login
|
</NButton>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<h1 class="text-3xl mb-3">
|
||||||
|
Login
|
||||||
|
</h1>
|
||||||
|
<NTextInput v-model="name" n="lg" class="w-100 m-auto" placeholder="Enter your name..." @keypress.enter="login()" />
|
||||||
|
<div class="mt-3">
|
||||||
|
<NButton icon="carbon:user" :disabled="!name" @click="login">
|
||||||
|
Log in
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #tips>
|
||||||
|
<div>
|
||||||
|
This demo showcases using the
|
||||||
|
<NLink href="https://v3.nuxtjs.org/docs/usage/cookies" target="_blank">
|
||||||
|
useCookie
|
||||||
|
</NLink>
|
||||||
|
API to persist small amounts of data that can be used both client-side and server-side.
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NuxtExampleLayout>
|
||||||
|
</template>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-use-cookie",
|
"name": "example-use-cookie",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,20 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
Server response: {{ data }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
const { data } = await useFetch('/api/hello', { params: { foo: 'bar' } })
|
const { data } = await useFetch('/api/hello', { params: { foo: 'bar' } })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NuxtExampleLayout example="use-fetch" show-tips="true">
|
||||||
|
Server response
|
||||||
|
<pre class="text-left"><code>{{ data }}</code></pre>
|
||||||
|
<template #tips>
|
||||||
|
<div>
|
||||||
|
Nuxt will automatically read in files in the
|
||||||
|
<a href="https://v3.nuxtjs.org/docs/directory-structure/server#api-routes" target="_blank">
|
||||||
|
<code>~/server/api</code> directory
|
||||||
|
</a>
|
||||||
|
to create API endpoints. Learn more about
|
||||||
|
<a href="https://v3.nuxtjs.org/docs/usage/data-fetching" target="_blank">data fetching</a>.
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</NuxtExampleLayout>
|
||||||
|
</template>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-use-fetch",
|
"name": "example-use-fetch",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<NuxtExampleLayout example="use-meta" :show-tips="true">
|
||||||
Hello World
|
<div
|
||||||
|
class="bg-gray-400/10 border-2 border-dashed border-gray-400/50 rounded-xl py-8 px-2 op-80"
|
||||||
|
>
|
||||||
|
There are renderless <code><Html></code>, <code><Meta></code>, <code><Title></code> components
|
||||||
|
<br>that can magically bind the meta using Vue template.
|
||||||
|
</div>
|
||||||
|
|
||||||
<Html :lang="String(dynamic)">
|
<Html :lang="String(dynamic)">
|
||||||
<Head>
|
<Head>
|
||||||
<Title>{{ dynamic }} title</Title>
|
<Title>Luck number: {{ dynamic }}</Title>
|
||||||
<Meta name="description" :content="`My page's ${dynamic} description`" />
|
<Meta name="description" :content="`My page's ${dynamic} description`" />
|
||||||
<Link rel="preload" href="/test.txt" as="script" />
|
<Link rel="preload" href="/test.txt" as="script" />
|
||||||
</Head>
|
</Head>
|
||||||
</Html>
|
</Html>
|
||||||
|
|
||||||
<button class="blue" @click="dynamic = Math.random() * 100">
|
<div class="mt-5">
|
||||||
Clickme
|
<NButton @click="dynamic = Math.round(Math.random() * 100)">
|
||||||
</button>
|
Click me and see the dynamic title
|
||||||
|
</NButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #tips>
|
||||||
|
<div class="flex-auto">
|
||||||
|
Learn more about
|
||||||
|
<NLink href="https://v3.nuxtjs.org/docs/usage/meta-tags" target="_blank">
|
||||||
|
Meta tags
|
||||||
|
</NLink>.
|
||||||
|
Open in editor to see the source code 👉
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
</NuxtExampleLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup () {
|
setup () {
|
||||||
useMeta({
|
useMeta({
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-use-meta",
|
"name": "example-use-meta",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
|
"dev": "nuxi dev",
|
||||||
"start": "node .output/server"
|
"start": "node .output/server"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,26 @@ const counter = useState('counter', () => Math.round(Math.random() * 1000))
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<NuxtExampleLayout :show-tips="true" example="use-state">
|
||||||
|
<div>Counter: {{ counter }}</div>
|
||||||
<div>
|
<div>
|
||||||
Counter: {{ counter }}
|
<NButton class="font-mono" @click="counter++">
|
||||||
<button @click="counter++">
|
|
||||||
+
|
+
|
||||||
</button>
|
</NButton>
|
||||||
<button @click="counter--">
|
<NButton class="font-mono" @click="counter--">
|
||||||
-
|
-
|
||||||
</button>
|
</NButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #tips>
|
||||||
|
<div>
|
||||||
|
<NLink href="https://v3.nuxtjs.org/docs/usage/state" target="_blank">
|
||||||
|
useState
|
||||||
|
</NLink>
|
||||||
|
is an SSR-friendly ref replacement.
|
||||||
|
Its value will be preserved after server-side rendering
|
||||||
|
and shared across all components using a unique key.
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
</NuxtExampleLayout>
|
||||||
|
</template>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-use-state",
|
"name": "example-use-state",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"extends": "./.nuxt/tsconfig.json"
|
"extends": "./.nuxt/tsconfig.json",
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<NuxtExampleLayout :show-tips="true" example="with-components">
|
||||||
|
<h1 class="text-xl opacity-50">
|
||||||
|
Auto Imported Components
|
||||||
|
</h1>
|
||||||
<div>
|
<div>
|
||||||
<hello-world />
|
<!-- Auto Imported Components -->
|
||||||
<nuxt3 />
|
<HelloWorld class="text-2xl" />
|
||||||
|
<Nuxt3 class="text-2xl" />
|
||||||
|
<ParentFolderHello class="mt-6" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #tips>
|
||||||
|
<div>
|
||||||
|
Components under <code>components/</code> folder are auto imported and can be directly used in your templates.
|
||||||
|
Read more about
|
||||||
|
<NLink href="https://v3.nuxtjs.org/docs/directory-structure/components" target="_blank">
|
||||||
|
the components directory.
|
||||||
|
</NLink>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
</NuxtExampleLayout>
|
||||||
|
</template>
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
<template>
|
||||||
|
<NCard class="flex flex-col gap-1 p-4">
|
||||||
|
Components in sub folders
|
||||||
|
<code class="op50">`components/parent-folder/hello.vue`</code>
|
||||||
|
can be auto imported with folder name as the prefix:
|
||||||
|
<code class="text-lime6"><ParentFolderHello/></code>
|
||||||
|
</NCard>
|
||||||
|
</template>
|
@ -1,5 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
Awesome Component
|
|
||||||
</div>
|
|
||||||
</template>
|
|
@ -1,7 +1,9 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
vite: false,
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
],
|
||||||
components: {
|
components: {
|
||||||
dirs: [
|
dirs: [
|
||||||
'~/components',
|
'~/components',
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-with-components",
|
"name": "example-with-components",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-with-composables",
|
"name": "example-with-composables",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-with-layouts",
|
"name": "example-with-layouts",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,32 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const route = useRoute()
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<NuxtExampleLayout example="with-pages">
|
||||||
<NuxtLink to="/">
|
<NuxtPage />
|
||||||
|
|
||||||
|
<template #nav>
|
||||||
|
<nav class="flex align-center gap-4 p-4">
|
||||||
|
<NuxtLink to="/" class="n-link-base">
|
||||||
Home
|
Home
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink to="/about">
|
<NuxtLink to="/about" class="n-link-base">
|
||||||
About
|
About
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink to="/parent">
|
<NuxtLink to="/parent" class="n-link-base">
|
||||||
Parent (index)
|
Parent (index)
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink to="/parent/b">
|
<NuxtLink to="/parent/b" class="n-link-base">
|
||||||
Parent (b)
|
Parent (b)
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
</nav>
|
||||||
|
</template>
|
||||||
|
|
||||||
<NuxtPage />
|
<template #footer>
|
||||||
|
<div class="text-center p-4 op-50">
|
||||||
|
Current route: <code>{{ route.path }}</code>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
</NuxtExampleLayout>
|
||||||
|
</template>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "example-with-pages",
|
"name": "example-with-pages",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
|
||||||
"nuxt3": "latest"
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"dev": "nuxi dev",
|
||||||
|
"start": "nuxi preview"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
|
||||||
|
"nuxt3": "latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
const a = ref(100)
|
const a = ref(100)
|
||||||
const b = ref(250)
|
const b = ref(250)
|
||||||
@ -9,11 +8,7 @@ const { data } = await useAsyncData('sum',
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<NuxtExampleLayout example="with-wasm">
|
||||||
<input v-model="a" type="number" readonly>
|
{{ a }} + {{ b }} = {{ data.sum }}
|
||||||
+
|
</NuxtExampleLayout>
|
||||||
<input v-model="b" type="number" readonly>
|
|
||||||
=
|
|
||||||
<input v-model="data.sum" type="number" readonly>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
@ -5,5 +5,8 @@ export default defineNuxtConfig({
|
|||||||
experiments: {
|
experiments: {
|
||||||
wasm: true
|
wasm: true
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
"dev": "nuxi dev",
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"start": "nuxi preview"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,13 @@
|
|||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"nuxt3": "workspace:./packages/nuxt3",
|
"nuxt3": "workspace:./packages/nuxt3",
|
||||||
|
"@nuxt/ui": "npm:@nuxt/ui-edge@^0.0.0-27337800.43e0b6e",
|
||||||
"unbuild": "^0.6.7",
|
"unbuild": "^0.6.7",
|
||||||
"jiti": "^1.12.9"
|
"jiti": "^1.12.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@iconify-json/carbon": "^1.0.12",
|
||||||
|
"@nuxt/ui": "^0.0.0-alpha.5",
|
||||||
"@nuxtjs/eslint-config": "^7.0.0",
|
"@nuxtjs/eslint-config": "^7.0.0",
|
||||||
"@nuxtjs/eslint-config-typescript": "^7.0.2",
|
"@nuxtjs/eslint-config-typescript": "^7.0.2",
|
||||||
"@types/chai": "^4.3.0",
|
"@types/chai": "^4.3.0",
|
||||||
@ -39,6 +42,7 @@
|
|||||||
"@types/mocha": "^9.0.0",
|
"@types/mocha": "^9.0.0",
|
||||||
"@types/node": "^14.18.2",
|
"@types/node": "^14.18.2",
|
||||||
"@types/object-hash": "^2",
|
"@types/object-hash": "^2",
|
||||||
|
"@unocss/reset": "^0.15.5",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"esbuild": "^0.14.8",
|
"esbuild": "^0.14.8",
|
||||||
"eslint": "^8.5.0",
|
"eslint": "^8.5.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app">
|
<div class="app">
|
||||||
<img src="~/assets/logo.svg" height="40">
|
<img src="~/assets/logo.svg" class="h-20 mb-4">
|
||||||
<h1 class="greeting">
|
<h1 class="greeting">
|
||||||
{{ hello }}, <br>Nuxt 3!
|
{{ hello }}, <br>Nuxt 3!
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { defineNuxtConfig } from 'nuxt3'
|
import { defineNuxtConfig } from 'nuxt3'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
modules: [
|
||||||
|
'@nuxt/ui'
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nuxi dev",
|
"dev": "nuxi dev",
|
||||||
"build": "nuxi build",
|
"build": "nuxi build",
|
||||||
"start": "node .output/server/index.mjs"
|
"start": "nuxi preview"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user