diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac87ccc4c..d1e19fb34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,7 +112,6 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] module: ['bundler', 'node'] - base: ['with-base-url', 'without-base-url'] steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 @@ -135,7 +134,6 @@ jobs: run: pnpm test:types env: MODULE_RESOLUTION: ${{ matrix.module }} - TS_BASE_URL: ${{ matrix.base }} lint: # autofix workflow will be triggered instead for PRs diff --git a/.website/.gitignore b/.website/.gitignore new file mode 100755 index 000000000..69f6b69d0 --- /dev/null +++ b/.website/.gitignore @@ -0,0 +1,12 @@ +node_modules +*.iml +.idea +*.log* +.nuxt +.vscode +.DS_Store +coverage +dist +sw.* +.env +.output diff --git a/.website/README.md b/.website/README.md new file mode 100755 index 000000000..610b0a4d5 --- /dev/null +++ b/.website/README.md @@ -0,0 +1,35 @@ +# Nuxt Docs Website + +This is a temporary directory until we open source the repository for nuxt.com. + +The goal is to simplify the contribution in the meantine to the documentation by having the possibility to preview the changes locally. + +## Setup + +Install dependencies in the root of the `nuxt` folder: + +```bash +pnpm i +``` + +Then stub the dependencies: + +```bash +pnpm build:stub +``` + +## Development + +In the root of the `nuxt` folder, run: + +```bash +pnpm docs:dev +``` + +Then open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +Update the documentation within the `docs` folder. + +--- + +For a detailed explanation of how things work, check out [Docus](https://docus.dev). diff --git a/.website/app.config.ts b/.website/app.config.ts new file mode 100644 index 000000000..9692072ac --- /dev/null +++ b/.website/app.config.ts @@ -0,0 +1,14 @@ +export default defineAppConfig({ + docus: { + title: 'Nuxt Docs [dev]', + description: 'The best place to start your documentation.', + socials: { + twitter: 'nuxt_js', + github: 'nuxt/nuxt' + }, + aside: { + level: 1, + collapsed: false, + }, + } +}) diff --git a/.website/nuxt.config.ts b/.website/nuxt.config.ts new file mode 100755 index 000000000..8de14298a --- /dev/null +++ b/.website/nuxt.config.ts @@ -0,0 +1,20 @@ +import { createResolver } from 'nuxt/kit' + +const { resolve } = createResolver(import.meta.url) + +export default defineNuxtConfig({ + // https://github.com/nuxt-themes/docus + extends: '@nuxt-themes/docus', + content: { + sources: { + docs: { + driver: 'fs', + prefix: '/', + base: resolve('../docs') + } + } + }, + experimental: { + renderJsonPayloads: false + } +}) diff --git a/.website/package.json b/.website/package.json new file mode 100755 index 000000000..2d49c9d6a --- /dev/null +++ b/.website/package.json @@ -0,0 +1,14 @@ +{ + "name": "docus-starter", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "nuxt dev", + "build": "nuxt build", + "generate": "nuxt generate", + "preview": "nuxt preview" + }, + "devDependencies": { + "@nuxt-themes/docus": "1.14.6" + } +} diff --git a/.website/tsconfig.json b/.website/tsconfig.json new file mode 100755 index 000000000..4b34df157 --- /dev/null +++ b/.website/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "./.nuxt/tsconfig.json" +} diff --git a/docs/1.getting-started/10.deployment.md b/docs/1.getting-started/10.deployment.md index 071316578..672d1c5f6 100644 --- a/docs/1.getting-started/10.deployment.md +++ b/docs/1.getting-started/10.deployment.md @@ -81,52 +81,61 @@ There are two ways to deploy a Nuxt application to any static hosting services: ### Crawl-based Pre-rendering -Use the [`nuxi generate` command](/docs/api/commands/generate) to build your application. For every page, Nuxt uses a crawler to generate a corresponding HTML and payload files. The built files will be generated in the `.output/public` directory. +Use the [`nuxi generate` command](/docs/api/commands/generate) to build and pre-render your application using the [Nitro](/docs/guide/concepts/server-engine) crawler. This command is similar to `nuxt build` with the `nitro.static` option set to `true`, or running `nuxt build --prerender`. ```bash npx nuxi generate ``` -You can enable crawl-based pre-rendering when using `nuxt build` in the `nuxt.config` file: +That's it! You can now deploy the `.output/public` directory to any static hosting service or preview it locally with `npx serve .output/public`. -```ts [nuxt.config.ts|js] -defineNuxtConfig({ - nitro: { - prerender: { - crawlLinks: true - } - } -}) -``` +Working of the Nitro crawler: + +1. Load the HTML of your application's root route (`/`), any non-dynamic pages in your `~/pages` directory, and any other routes in the `nitro.prerender.routes` array. +2. Save the HTML and `payload.json` to the `~/.output/public/` directory to be served statically. +3. Find all anchor tags (``) in the HTML to navigate to other routes. +4. Repeat steps 1-3 for each anchor tag found until there are no more anchor tags to crawl. + +This is important to understand since pages that are not linked to a discoverable page can't be pre-rendered automatically. + +::alert{type=info} +Read more about the [`nuxi generate` command](/docs/api/commands/generate#nuxi-generate). +:: ### Selective Pre-rendering -You can manually specify routes that [Nitro](/docs/guide/concepts/server-engine) will fetch and pre-render during the build. +You can manually specify routes that [Nitro](/docs/guide/concepts/server-engine) will fetch and pre-render during the build or ignore routes that you don't want to pre-render like `/dynamic` in the `nuxt.config` file: ```ts [nuxt.config.ts|js] defineNuxtConfig({ nitro: { prerender: { routes: ['/user/1', '/user/2'] + ignore: ['/dynamic'] } } }) ``` -When using this option with `nuxi build`, static payloads won't be generated by default at build time. For now, selective payload generation is under an experimental flag. +You can combine this with the `crawLinks` option to pre-render a set of routes that the crawler can't discover like your `/sitemap.xml` or `/robots.txt`: ```ts [nuxt.config.ts|js] defineNuxtConfig({ - /* The /dynamic route won't be crawled */ nitro: { - prerender: { crawlLinks: true, ignore: ['/dynamic'] } - }, - experimental: { - payloadExtraction: true + prerender: { + crawlLinks: true, + routes: ['/sitemap.xml', '/robots.txt'] + } } }) ``` +Setting `nitro.prerender` to `true` is similar to `nitro.prerender.crawlLinks` to `true`. + +::alert{type=info} +Read more about [pre-rendering](https://nitro.unjs.io/config#prerender) in the Nitro documentation. +:: + ### Client-side Only Rendering If you don't want to pre-render your routes, another way of using static hosting is to set the `ssr` property to `false` in the `nuxt.config` file. The `nuxi generate` command will then output an `.output/public/index.html` entrypoint and JavaScript bundles like a classic client-side Vue.js application. diff --git a/docs/1.getting-started/5.routing.md b/docs/1.getting-started/5.routing.md index 9209b8525..3f5ce8de0 100644 --- a/docs/1.getting-started/5.routing.md +++ b/docs/1.getting-started/5.routing.md @@ -71,7 +71,7 @@ When a `` enters the viewport on the client side, Nuxt will automatica The `useRoute()` composable can be used in a `