Skip to content

Commit

Permalink
Merge pull request #86 from basics/feature/docs-nuxt-3
Browse files Browse the repository at this point in the history
docs(pages): added integration nuxt 3
  • Loading branch information
ThornWalli authored Jan 27, 2025
2 parents 8cf388d + d685bc0 commit 7d524f3
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/.vitepress/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default {
{ text: 'ContentHeadline', link: '/components/content-headline' },
{ text: 'ContentContainer', link: '/components/content-container' }
]
},
{
text: 'Integration',
items: [{ text: 'Nuxt 3', link: '/integration/nuxt-3' }]
}
],

Expand Down
123 changes: 123 additions & 0 deletions docs/src/integration/nuxt-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
title: Nuxt 3 Integration
---

# {{$frontmatter.title}}

The integration in Nuxt is done in a few steps.

The following settings must be adjusted:

- Layout
- Page Component

## Layout

In the layout, the component `ContentContainer` must be placed around the respective page slot.
The `ContentContainer` defined there represents the `main` of the page.

::: code-group

```vue [layouts/default.vue]
<template>
<div>
<!-- main -->
<ContentContainer>
<slot />
</ContentContainer>
</div>
</template>
<script setup>
import { ContentContainer } from 'vue-semantic-structure'
</script>
```

:::

## Page Component

With the exception of the first component, each additional component must contain a `ContentContainer`.

::: code-group

```vue[pages/index.vue]
<template>
<div>
<FirstComponent />
<OtherComponentA />
<OtherComponentB />
</div>
</template>
<script setup>
import FirstComponent from '~/components/FirstComponent.vue'
import OtherComponentA from '~/components/OtherComponentA.vue'
import OtherComponentB from '~/components/OtherComponentB.vue'
```

```vue[FirstComponent.vue]
<template>
<header>
<!-- h1 -->
<ContentHeadline>Headline</ContentHeadline>
</header>
</template>
<script setup>
import { ContentHeadline } from 'vue-semantic-structure'
</script>
```

```vue[OtherComponentA.vue]
<template>
<!-- article -->
<ContentContainer>
<!-- h2 -->
<ContentHeadline>Headline</ContentHeadline>
</ContentContainer>
</template>
<script setup>
import { ContentContainer, ContentHeadline } from 'vue-semantic-structure'
</script>
```

```vue[OtherComponentB.vue]
<template>
<!-- article -->
<ContentContainer>
<!-- h2 -->
<ContentHeadline>Headline</ContentHeadline>
</ContentContainer>
</template>
<script setup>
import { ContentContainer, ContentHeadline } from 'vue-semantic-structure'
</script>
```

:::

## Register Global

`ContentHeadline` and `ContentContainer` can also be defined globally.

Only one plugin needs to be created for this.

::: code-group

```js[Nuxt 3: plugin/vue-semantic-structure.js]
import { defineNuxtPlugin } from 'nuxt/app';
import { ContentHeadline, ContentContainer } from 'vue-semantic-structure';
export default defineNuxtPlugin({
async setup(nuxtApp) {
nuxtApp.vueApp.component('ContentHeadline', ContentHeadline);
nuxtApp.vueApp.component('ContentContainer', ContentContainer);
}
});
```

:::

0 comments on commit 7d524f3

Please sign in to comment.