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

feat(nuxt): add setLayout utility #6826

Merged
merged 39 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5ec709f
Add `useLayout` composables change layouts
CoinPool-Coin Aug 22, 2022
19e603f
Add useLayout document
CoinPool-Coin Aug 22, 2022
89ca7d0
Resolution `Newline required at end of file but not found eol-last`
CoinPool-Coin Aug 22, 2022
2858c85
Merge branch 'main' into main
HomWang Aug 22, 2022
c2a18fb
Merge branch 'nuxt:main' into main
HomWang Aug 22, 2022
fd40e04
Merge branch 'nuxt:main' into main
HomWang Aug 23, 2022
c59cd90
Add `tsx` and `template`, and change the content to `Welcome to nuxt3`
CoinPool-Coin Aug 23, 2022
0bf58cd
Rollback pages.md
CoinPool-Coin Aug 23, 2022
a25ebf4
Merge branch 'nuxt:main' into main
HomWang Aug 23, 2022
8a409a5
rm useLayout and Add examples/advanced/tsx example
CoinPool-Coin Aug 23, 2022
75b6f60
Resolution error Newline required at end of file but not found …
CoinPool-Coin Aug 23, 2022
bef858b
Add // @ts-ignore
CoinPool-Coin Aug 23, 2022
992bdcc
Add eslint-disable-next-line @typescript-eslint/no-unused-vars
CoinPool-Coin Aug 23, 2022
eca7d33
remove use-layout (not related to this pr)
pi0 Aug 23, 2022
07e5239
rename package name to `example-tsx`
pi0 Aug 23, 2022
0a67113
refactor: show few different usages of tsx to define a component render
pi0 Aug 23, 2022
0393a71
use nuxt/ui
pi0 Aug 23, 2022
691a446
rename to jsx (jsx / tsx)
pi0 Aug 23, 2022
badac5e
add example link to pages tsx usage
pi0 Aug 23, 2022
44c5bd3
trigger ci
pi0 Aug 23, 2022
f48bf5f
use auto imports
pi0 Aug 23, 2022
30e8ab2
Merge branch 'nuxt:main' into main
HomWang Aug 24, 2022
11f3fff
Add setLayout
CoinPool-Coin Aug 24, 2022
fb7017f
Merge branch 'main' of https://github.com/516310460/framework
CoinPool-Coin Aug 24, 2022
5248b22
fix eslint prompt
CoinPool-Coin Aug 24, 2022
d748bff
Merge branch 'nuxt:main' into main
HomWang Aug 24, 2022
4533b54
Add function tsx component
CoinPool-Coin Aug 25, 2022
0874377
Add function tsx component
CoinPool-Coin Aug 25, 2022
949c381
Merge branch 'nuxt:main' into main
HomWang Aug 25, 2022
47769b6
chore: revert changes
danielroe Aug 25, 2022
75825b9
refactor: preserve layout state from server -> client via meta
danielroe Aug 25, 2022
71918de
docs: update example
danielroe Aug 25, 2022
c11768c
docs: add `setLayout` documentation
danielroe Aug 25, 2022
6e885e7
test: add fixture
danielroe Aug 25, 2022
8085ab4
Merge remote-tracking branch 'origin/main' into 516310460/main
danielroe Aug 25, 2022
c1aa622
chore: remove unrelated files
danielroe Aug 25, 2022
0ab573f
chore: update with main
danielroe Aug 25, 2022
81d2f50
style: lint
danielroe Aug 25, 2022
33a7ad6
Merge branch 'nuxt:main' into main
HomWang Aug 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/content/3.api/1.composables/use-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `useLayout`

Within your pages, components, and plugins you can use useLayout to get access to data that resolves asynchronously.

**Usage:**

```vue
<template>
<button @click="useLayout('default')"></button>
</template>
```

## Params

* **layout**: A `layout` name to ensure that `layout` can be set correctly.
1 change: 1 addition & 0 deletions packages/nuxt/src/app/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { defineNuxtComponent } from './component'
export { useAsyncData, useLazyAsyncData, refreshNuxtData } from './asyncData'
export type { AsyncDataOptions, AsyncData } from './asyncData'
export { useHydration } from './hydrate'
export { useLayout } from './layout'
export { useState } from './state'
export { clearError, createError, isNuxtError, throwError, showError, useError } from './error'
export type { NuxtError } from './error'
Expand Down
6 changes: 6 additions & 0 deletions packages/nuxt/src/app/composables/layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { useRoute } from '#app'

export function useLayout (layout: string) {
const route = useRoute()
route.meta.layout = layout
}
1 change: 1 addition & 0 deletions packages/nuxt/src/auto-imports/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const appPreset = defineUnimportPreset({
'useAsyncData',
'useLazyAsyncData',
'refreshNuxtData',
'useLayout',
'defineNuxtComponent',
'useNuxtApp',
'defineNuxtPlugin',
Expand Down