Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into extends-app
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 4, 2022
2 parents c9c3f17 + d5b7b58 commit 41dc828
Show file tree
Hide file tree
Showing 307 changed files with 3,383 additions and 1,461 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"vue/multi-word-component-names": "off",
"vue/one-component-per-file": "off",
"vue/require-default-prop": "off",
"vue/no-multiple-template-root": "off",
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param": "off",
"jsdoc/require-returns": "off",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Welcome to Nuxt 3 repository ✨
- Ensure you have the latest LTS version of Node.js installed
- Install dependencies with `npx yarn install`
- Run `npx yarn stub` to activate passive development
- Open playground with `npx yarn play`
- Open playground with `npx yarn dev`

Learn more about in our documentation on [how to contribute to Nuxt](https://v3.nuxtjs.org/community/contribution).

Expand Down
7 changes: 6 additions & 1 deletion docs/components/app/AppLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="relative w-full">
<AppHeader :links="headerLinks" />

<div class="lg:flex" :class="{ 'd-container': layout.aside }">
<div class="lg:flex" :class="containerClass">
<slot v-if="['xs', 'sm', 'md'].includes($mq) || layout.aside" name="aside">
<AppAside :links="headerLinks" :class="layout.asideClass" />
</slot>
Expand Down Expand Up @@ -33,6 +33,11 @@ export default defineComponent({
computed: {
layout () {
return this.$docus.layout.value
},
containerClass () {
if (this.layout.aside && this.layout.fluid) { return 'd-container-fluid' }
if (this.layout.aside) { return 'd-container' }
return ''
}
}
})
Expand Down
107 changes: 107 additions & 0 deletions docs/components/atoms/Sandbox.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<template>
<div class="w-full min-h-[500px] mx-auto mb-6 overflow-hidden text-3xl rounded-md sandbox mt-4">
<TabsHeader
v-if="!src"
ref="tabs"
:active-tab-index="activeTabIndex"
:tabs="providersTabs"
@update="updateTab"
>
<div slot="footer" class="absolute top-1/2 transform -translate-y-1/2 right-0 px-2">
<Link class="flex items-center text-gray-500 dark:text-gray-400" :to="sandBoxUrl" blank>
<IconExternalLink class="h-5 w-5" />
</Link>
</div>
</TabsHeader>

<iframe
v-if="url"
:src="url"
title="Sandbox editor"
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
class="w-full h-full min-h-[700px] overflow-hidden bg-gray-100 dark:bg-gray-800"
/>
<span v-else class="text-white flex-1">Loading Sandbox...</span>
</div>
</template>

<script>
import {
defineComponent,
onMounted,
computed,
ref,
useContext
} from '@nuxtjs/composition-api'
export default defineComponent({
props: {
src: {
type: String
},
repo: {
type: String
},
branch: {
type: String
},
dir: {
type: String
},
file: {
type: String,
default: 'app.vue'
}
},
setup (props) {
const { $colorMode } = useContext()
const providers = {
CodeSandBox: () =>
`https://codesandbox.io/embed/github/${props.repo}/tree/${props.branch}/${props.dir}?hidenavigation=1&theme=${$colorMode.value}`,
StackBlitz: () =>
`https://stackblitz.com/github/${props.repo}/tree/${props.branch}/${props.dir}?embed=1&file=${props.file}&theme=${$colorMode.value}`
}
const providersTabs = Object.keys(providers).map(p => ({ label: p }))
const activeTabIndex = ref(-1)
const tabs = ref()
const url = ref('')
const provider = ref('')
function updateTab (i) {
activeTabIndex.value = i
changeProvider(providersTabs[i].label)
}
onMounted(() => {
// TODO: if Safari, use CodeSandBox by default: const defaultSandbox = ...
provider.value =
window.localStorage.getItem('docus_sandbox') || 'CodeSandBox'
url.value = props.src || providers[provider.value]()
// Set active tab
activeTabIndex.value = Object.keys(providers).indexOf(provider.value)
setTimeout(() => tabs.value.updateTabs(activeTabIndex.value), 100)
})
const changeProvider = (value) => {
provider.value = value
url.value = props.src || providers[provider.value]()
localStorage.setItem('docus_sandbox', value)
}
const sandBoxUrl = computed(() => url.value?.replace('?embed=1&', '?').replace('/embed/', '/s/'))
return {
tabs,
provider,
url,
sandBoxUrl,
changeProvider,
updateTab,
activeTabIndex,
providersTabs
}
}
})
</script>
<style lang="postcss" scoped>
.sandbox,
.sandbox iframe {
@apply w-full rounded-md rounded-tl-none rounded-tr-none overflow-hidden h-64;
height: 700px;
}
</style>
45 changes: 45 additions & 0 deletions docs/components/templates/Example.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<template>
<AppPage>
<PageContent :page="page" />
<template #prev-next>
<PagePrevNext :prev="prev" :next="next" />
</template>
</AppPage>
</template>

<script>
import {
defineComponent,
ref,
useContext,
useFetch
} from '@nuxtjs/composition-api'
export default defineComponent({
props: {
page: {
type: Object,
required: true
}
},
setup (props) {
const { $docus } = useContext()
const prev = ref(null)
const next = ref(null)
useFetch(async () => {
const [prevLink, nextLink] = await $docus.getPreviousAndNextLink(
props.page
)
prev.value = prevLink
next.value = nextLink
})
return {
prev,
next
}
},
templateOptions: {
aside: true,
fluid: false
}
})
</script>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Bridge
# Migrating to Bridge

Experience Nuxt 3 features on existing Nuxt 2 projects.

Expand Down Expand Up @@ -136,7 +136,7 @@ You may also need to add `@vue/runtime-dom` as a devDependency if you are strugg
::
::alert
Keep in mind that all options extended from `./.nuxt/tsconfig.json` will be overwritten by the options defined in your `tsconfig.json`.
Overwriting options such as `"compilerOptions.paths"` with your own configuration will lead Typescript to not factor in the module resolutions from `./.nuxt/tsconfig.json`. This can lead to module resolutions such as `#imports` not being recognized.
Overwriting options such as `"compilerOptions.paths"` with your own configuration will lead TypeScript to not factor in the module resolutions from `./.nuxt/tsconfig.json`. This can lead to module resolutions such as `#imports` not being recognized.

In case you need to extend options provided by `./.nuxt/tsconfig.json` further, you can use the `alias` property withing your `nuxt.config`. `nuxi` will pick them up and extend `./.nuxt/tsconfig.json` accordingly.
::
Expand Down Expand Up @@ -241,7 +241,7 @@ export default defineNuxtConfig({

// -- Opt-in features --

// Use Vite as the bundler instead of Webpack 4
// Use Vite as the bundler instead of webpack 4
// vite: true,

// Enable Nuxt 3 compatible useMeta
Expand Down
132 changes: 0 additions & 132 deletions docs/content/1.getting-started/6.migration.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/content/2.concepts/1.introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To understand what is Nuxt, we need to understand what we need to create a moder
::list{type=success}

- A JavaScript framework to bring reactivity and web components, we chose [Vue.js](https://v3.vuejs.org).
- A bundler to support hot module replacement in development and bundle your code for production, we support both [Webpack 5](https://webpack.js.org/) and [Vite](https://vitejs.dev/).
- A bundler to support hot module replacement in development and bundle your code for production, we support both [webpack 5](https://webpack.js.org/) and [Vite](https://vitejs.dev/).
- A transpiler in order to write the latest JavaScript syntax while supporting legacy browsers, we use [esbuild](https://esbuild.github.io) for that.
- A server for serving your application in development, but also to support [server-side rendering](https://vuejs.org/api/ssr.html#server-side-rendering-api) or API routes, Nuxt uses [h3](https://github.com/unjs/h3) for deployment versatility such as serverless, workers, Node.js and unmatched performance.
- A routing library to handle client-side navigation, we chose [vue-router](https://router.vuejs.org/).
Expand Down Expand Up @@ -47,4 +47,4 @@ Ready to try? Head over the [Installation section](/getting-started/installation

### Are you *courageously* Nuxt?

Take a stab at an open [issue](https://github.com/nuxt/framework/issues). This is actually the best way to learn Nuxt, by actually diving into the code. You may even bring an approach or alternative solution that makes Nuxt even better! So, what are you waiting for? Let's go!
Take a stab at an open [issue](https://github.com/nuxt/framework/issues). This is actually the best way to learn Nuxt, by actually diving into the code. You may even bring an approach or alternative solution that makes Nuxt even better! So, what are you waiting for? Let's go!
10 changes: 5 additions & 5 deletions docs/content/2.concepts/2.vuejs-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Nuxt 3 is based on Vue 3. The new Vue major version introduces several changes t

- Better performances
- Composition API
- Typescript support
- TypeScript support

### Faster rendering

Expand Down Expand Up @@ -100,13 +100,13 @@ Used with the `setup` keyword in the `<script>` definition, here is the above co

The goal of Nuxt 3 is to provide a great developer experience around the composition API.

- Use auto-imported [Reactivity functions](https://vuejs.org/api/reactivity-core.html) from Vue and Nuxt 3 [built-in composables](https://v3.nuxtjs.org/docs/usage/data-fetching).
- Use auto-imported [Reactivity functions](https://vuejs.org/api/reactivity-core.html) from Vue and Nuxt 3 [built-in composables](/docs/usage/data-fetching).
- Write your own auto-imported reusable functions in the `composables/` directory.

### Typescript support
### TypeScript support

Both Vue 3 and Nuxt 3 are written in Typescript. A fully typed codebase prevents mistakes and documents APIs usage. This doesn’t mean that you have to write your application in Typescript to take advantage of it. With Nuxt 3, you can opt-in by renaming your file from `.js` to `.ts` , or add `<script lang="ts">` in a component.
Both Vue 3 and Nuxt 3 are written in TypeScript. A fully typed codebase prevents mistakes and documents APIs usage. This doesn’t mean that you have to write your application in TypeScript to take advantage of it. With Nuxt 3, you can opt-in by renaming your file from `.js` to `.ts` , or add `<script lang="ts">` in a component.

::alert{type="info"}
🔎 [Read the details about Typescript in Nuxt 3](/concepts/typescript)
🔎 [Read the details about TypeScript in Nuxt 3](/concepts/typescript)
::
Loading

0 comments on commit 41dc828

Please sign in to comment.