From 1d2f57ec82b9c5f5b40e5f4316062b566e5f2d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Sat, 4 Mar 2023 22:30:35 +0100 Subject: [PATCH] docs: fix on mobile long path --- .../1.introduction/0.getting-started.md | 19 +++++----- .../1.guide/1.introduction/1.configuration.md | 36 +++++++++++++------ .../1.guide/1.introduction/2.auto-imports.md | 15 ++++++-- .../content/1.guide/1.introduction/5.cache.md | 2 +- 4 files changed, 49 insertions(+), 23 deletions(-) diff --git a/docs/content/1.guide/1.introduction/0.getting-started.md b/docs/content/1.guide/1.introduction/0.getting-started.md index 1ce27cedc9..507a7279a8 100644 --- a/docs/content/1.guide/1.introduction/0.getting-started.md +++ b/docs/content/1.guide/1.introduction/0.getting-started.md @@ -4,10 +4,10 @@ Let's create a new Nitro app in few steps. ## Play Online -:button-link[Open on Stackblitz]{href="https://stackblitz.com/github/unjs/nitro/tree/main/examples/hello-world" icon="simple-icons:stackblitz" blank style="margin-right: 10px;"} +:button-link[Open on Stackblitz]{href="https://stackblitz.com/github/unjs/nitro/tree/main/examples/hello-world" icon="simple-icons:stackblitz" blank style="margin-right: 10px;margin-bottom:10px;"} :button-link[Open on CodeSandox]{href="https://codesandbox.io/p/sandbox/nitro-template-5jssbm" icon="simple-icons:codesandbox" blank} -## Using Starter Template +## Starter Template Before getting started, please make sure you have installed the recommended setup: @@ -17,7 +17,6 @@ Before getting started, please make sure you have installed the recommended setu Create a new project using starter template: - ::code-group ```bash [npx] @@ -53,10 +52,10 @@ pnpm install :: -Start development server: +Start the development server: ```bash -npx nitropack dev +npm run dev ``` 🪄 Your API is ready at `http://localhost:3000/` @@ -65,15 +64,17 @@ npx nitropack dev Check `.nitro/dev/index.mjs` if want to know what is happening :: -You can now build your production-ready server: +Build your production-ready server: ```bash -npx nitropack build +npm run build ```` -Output is in the `.output` directory and ready to be deployed on almost any provider with no dependencies. You can locally try it too: +Output is in the `.output` directory and ready to be deployed on almost any provider with no dependencies. + +You can try it locally with: ```bash -node .output/server/index.mjs +npm run preview ``` diff --git a/docs/content/1.guide/1.introduction/1.configuration.md b/docs/content/1.guide/1.introduction/1.configuration.md index 5673a2a029..b6f95d7603 100644 --- a/docs/content/1.guide/1.introduction/1.configuration.md +++ b/docs/content/1.guide/1.introduction/1.configuration.md @@ -1,23 +1,37 @@ # Configuration -Customize your Nitro app with a configuration file. +You can customize your Nitro server with single configuration file: `nitro.config.ts`. -In order to customize nitro's behavior, we can use `nitro.config.ts`. +All deployment providers are built on the same options API. -It is powerful enough that all deployment providers are built on the same options API. - -Create a new `nitro.config.ts` file to provide options: +If you are using [Nuxt](https://nuxt.com), use the `nitro` option in your Nuxt config. +::code-group ```ts [nitro.config.ts] import { defineNitroConfig } from 'nitropack' export default defineNitroConfig({ - // Your options + // Nitro options +}) +``` +```ts [nuxt.config.ts] +export default defineNuxtConfig({ + nitro: { + // Nitro options + } }) ``` - -::alert -**More Features Available!** -:br -Nitro handles configuration loading using [unjs/c12](https://github.com/unjs/c12). You have more advanced possibilities such as using `.env`. And `.nitrorc`. :: + +Read all the [available options](/config) to configure Nitro. + +Nitro loads the configuration using [unjs/c12](https://github.com/unjs/c12), giving more possibilities such as using `.nitrorc`. + +::code-group +```txt [.nitrorc] +timing=true +``` +```txt [.nuxtrc] +nitro.timing=true +``` +:: \ No newline at end of file diff --git a/docs/content/1.guide/1.introduction/2.auto-imports.md b/docs/content/1.guide/1.introduction/2.auto-imports.md index 52c334a18c..235a01a032 100644 --- a/docs/content/1.guide/1.introduction/2.auto-imports.md +++ b/docs/content/1.guide/1.introduction/2.auto-imports.md @@ -1,15 +1,26 @@ # Auto Imports -Nitro is integrated with [unjs/unimport](https://github.com/unjs/unimport) and automatically imports utilities by usage with full tree-shaking support. +Nitro is using [unjs/unimport](https://github.com/unjs/unimport) to auto import utilities when used with full tree-shaking support. ## Available Auto Imports +- `defineCachedFunction(fn, options)`{lang=ts} / `cachedFunction(fn, options)`{lang=ts} +- `defineCachedEventHandler(handler, options)`{lang=ts} +- `cachedEventHandler(handler, options)`{lang=ts} +- `useRuntimeConfig()`{lang=ts} +- `useStorage(base?)`{lang=ts} +- `useNitroApp()`{lang=ts} +- `defineNitroPlugin(plugin)`{lang=ts} +- `nitroPlugin(plugin)`{lang=ts} +- `defineRenderHandler` + "getRouteRules", + Check [the source code](https://github.com/unjs/nitro/blob/main/src/imports.ts) for list of available auto imports. With [TypeScript](/guide/introduction/typescript) enabled, you can easily see them as global utilities in your IDE. ::alert{type="info"} -Run `npx nitropack prepare` to generate the types for global auto-imports. +The types are auto generated for global auto-imports when running the `prepare` or `dev` command. :: ## Manual Imports diff --git a/docs/content/1.guide/1.introduction/5.cache.md b/docs/content/1.guide/1.introduction/5.cache.md index f31fd17cd4..f594ff27ed 100644 --- a/docs/content/1.guide/1.introduction/5.cache.md +++ b/docs/content/1.guide/1.introduction/5.cache.md @@ -99,7 +99,7 @@ export default eventHandler(async (event) => { ``` :: -The stars will be cached in development inside `.nitro/cache/functions/ghStars//.json` with `value` being the number of stars. +The stars will be cached in development inside **.nitro/cache/functions/ghStars/<owner>/<repo>.json** with `value` being the number of stars. ```json {"expires":1677851092249,"value":43991,"mtime":1677847492540,"integrity":"ZUHcsxCWEH"}