PageBody

ページのメインコンテンツ。

使用法

PageBodyコンポーネントはメインコンテンツをラップし、一貫した間隔のためにパディングを追加します。

Pageコンポーネントのデフォルトスロット内、 PageHeaderコンポーネントの後に使用します。

<template>
  <UPage>
    <UPageHeader />

    <UPageBody />
  </UPage>
</template>

サンプル

これらの例はNuxt Contentを使用していますが、コンポーネントは任意のコンテンツ管理システムと統合できます。

ページ内

ページ内のPageBodyコンポーネントを使用して、ページのコンテンツを表示します。

pages/[...slug].vue
<script setup lang="ts">
const route = useRoute()

definePageMeta({
  layout: 'docs'
})

const { data: page } = await useAsyncData(route.path, () => {
  return queryCollection('docs').path(route.path).first()
})

const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
  return queryCollectionItemSurroundings('content', route.path)
})
</script>

<template>
  <UPage>
    <UPageHeader :title="page.title" :description="page.description" />

    <UPageBody>
      <ContentRenderer :value="page" />

      <USeparator />

      <UContentSurround :surround="surround" />
    </UPageBody>

    <template #right>
      <UContentToc :links="page.body.toc.links" />
    </template>
  </UPage>
</template>
この例では、@nuxt/contentのContentRendererコンポーネントを使用してページのコンテンツをレンダリングします。

API

Props

Prop Default Type
as
'div'
any

The element or component this component should render as.

ui
{ base?: any; }

スロット

Slot Type
default
{}

Theme

app.config.ts
export default defineAppConfig({
  ui: {
    pageBody: {
      base: 'mt-8 pb-24 space-y-12'
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      ui: {
        pageBody: {
          base: 'mt-8 pb-24 space-y-12'
        }
      }
    })
  ]
})

Changelog

No recent changes