Skip to content

Commit bf5f56a

Browse files
committed
fix(content): prepare for nuxt content v3
1 parent cac09e8 commit bf5f56a

30 files changed

+38
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ env/cert/*
3434

3535
dist
3636
.output
37+
.data

.lintstagedrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"eslint ."
44
],
55
"*.(vue|css)": [
6-
"stylelint --fix"
6+
"stylelint"
77
]
88
}

content.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineContentConfig, defineCollection } from '@nuxt/content';
2+
3+
export default defineContentConfig({
4+
collections: {
5+
page: defineCollection({
6+
type: 'page',
7+
source: 'pages/**/*.json'
8+
}),
9+
layout: defineCollection({
10+
type: 'page',
11+
source: 'layout/**.json'
12+
})
13+
}
14+
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/components/fragment/LanguageSwitch.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<template>
22
<fragment-link-list class="fragment-language-switch">
33
<li v-for="language in languages" :key="language.code">
4-
<site-link
4+
<nuxt-link
55
:to="switchLocalePath(language.code)"
66
class="language-switch"
77
:title="language.code"
88
>
99
{{ language.code }}
10-
</site-link>
10+
</nuxt-link>
1111
</li>
1212
</fragment-link-list>
1313
</template>

src/components/fragment/LinkList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
>
77
<slot>
88
<li v-for="item in list" :key="item.title">
9-
<site-link :to="localePath(item.to)">
9+
<nuxt-link :to="localePath(item.to)">
1010
{{ item.title }}
11-
</site-link>
11+
</nuxt-link>
1212
</li>
1313
</slot>
1414
</ul>

src/components/module/TextImage.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<fragment-content
1212
v-bind="{ headline: { overline, headline, subline }, content }"
1313
/>
14-
<site-link v-if="link" v-bind="{ ...link, to: localePath(link.to) }">{{
14+
<nuxt-link v-if="link" v-bind="{ ...link, to: localePath(link.to) }">{{
1515
link.title
16-
}}</site-link>
16+
}}</nuxt-link>
1717
</template>
1818
</base-layout-two-column-container>
1919
</base-content-container>

src/components/page/Header.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
>
77
<template #container>
88
<div class="logo">
9-
<site-link
9+
<nuxt-link
1010
:to="
1111
localePath({
1212
path: '/'
1313
})
1414
"
1515
>
1616
Logo
17-
</site-link>
17+
</nuxt-link>
1818
</div>
1919
</template>
2020
</base-layout-lost-container>

src/components/page/Menu.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<nav>
44
<fragment-link-list class="links" type="page-menu-links">
55
<li v-for="item in navigation" :key="item.title">
6-
<site-link :to="localePath(item.to)">
6+
<nuxt-link :to="localePath(item.to)">
77
{{ item.title }}
8-
</site-link>
8+
</nuxt-link>
99
<fragment-link-list
1010
v-if="item.childs && item.childs.length"
1111
:list="item.childs"

src/composables/pageContent.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRoute, queryContent, useSetI18nParams } from '#imports';
1+
import { useRoute, queryCollection, useSetI18nParams } from '#imports';
22

33
export function usePageContent() {
44
const route = useRoute();
@@ -7,11 +7,10 @@ export function usePageContent() {
77
return {
88
fetch: async () => {
99
try {
10-
const path = normalizePath(route.path).replace('/index', '');
11-
const { title, components, i18nParams } = await queryContent(
12-
'pages',
13-
path
14-
).findOne();
10+
const path = `/pages${normalizePath(route.path).replace('/index', '')}`;
11+
const {
12+
body: { title, components, i18nParams }
13+
} = await queryCollection('page').path(path).first();
1514

1615
if (!import.meta.server) {
1716
setI18nParams(i18nParams);

src/layouts/default.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
<template>
22
<base-content-container>
33
<template #before>
4-
<page-header v-bind="layoutData?.components.pageHeader" sticky />
4+
<page-header v-bind="layoutData?.body.components.pageHeader" sticky />
55
</template>
66
<template #default>
77
<page-menu
88
class="page-menu"
9-
v-bind="layoutData?.components.pageMenu"
9+
v-bind="layoutData?.body.components.pageMenu"
1010
:opened="!preventMenuOpened"
1111
/>
1212
<page-menu-button
13-
v-bind="layoutData?.components.pageMenuButton"
13+
v-bind="layoutData?.body.components.pageMenuButton"
1414
@click="onClickMenuButton"
1515
/>
1616
<slot />
1717
</template>
1818
<template #after>
19-
<page-footer v-bind="layoutData?.components.pageFooter" />
19+
<page-footer v-bind="layoutData?.body.components.pageFooter" />
2020
</template>
2121
</base-content-container>
2222
</template>
2323

2424
<script setup>
2525
import {
26-
queryContent,
26+
queryCollection,
2727
useI18n,
2828
useAsyncData,
2929
useBoosterHydrate
@@ -53,8 +53,8 @@ const { locale } = useI18n();
5353
5454
const { data: layoutData } = await useAsyncData(
5555
`layout-data-${locale.value}`,
56-
() => {
57-
return queryContent('layout', locale.value).findOne();
56+
async () => {
57+
return queryCollection('layout').path(`/layout/${locale.value}`).first();
5858
},
5959
{ watch: [locale] }
6060
);

0 commit comments

Comments
 (0)