version update to nuxt4

This commit is contained in:
Julian Krauser 2025-07-23 13:46:18 +02:00
parent 7f1770d442
commit ef84942e38
41 changed files with 5134 additions and 4946 deletions

View file

@ -54,10 +54,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type Article from "../types/collection/article"; import type Article from "~~/types/collection/article";
import type Operation from "../types/collection/operation"; import type Operation from "~~/types/collection/operation";
import type Event from "../types/collection/event"; import type Event from "~~/types/collection/event";
import type Vehicle from "../types/collection/vehicle"; import type Vehicle from "~~/types/collection/vehicle";
const runtimeConfig = useRuntimeConfig(); const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url; const baseUrl = runtimeConfig.public.strapi.url;

View file

@ -23,8 +23,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type ItemsHero from "../types/component/items/hero"; import type ItemsHero from "~~/types/component/items/hero";
import type { ComponentTypes } from "../types/component/baseComponent"; import type { ComponentTypes } from "~~/types/component/baseComponent";
defineProps({ defineProps({
hero: { type: Object as PropType<ItemsHero>, required: false, default: null }, hero: { type: Object as PropType<ItemsHero>, required: false, default: null },

View file

@ -36,8 +36,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type BaseCollection from "~/types/collection/baseCollection"; import type BaseCollection from "~~/types/collection/baseCollection";
import type Lookup from "../../types/collection/lookup"; import type Lookup from "~~/types/collection/lookup";
const runtimeConfig = useRuntimeConfig(); const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url; const baseUrl = runtimeConfig.public.strapi.url;

View file

@ -22,8 +22,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type BaseCollection from "../../types/collection/baseCollection"; import type BaseCollection from "~~/types/collection/baseCollection";
import type Lookup from "../../types/collection/lookup"; import type Lookup from "~~/types/collection/lookup";
const props = defineProps({ const props = defineProps({
data: Object as PropType<BaseCollection>, data: Object as PropType<BaseCollection>,

View file

@ -13,7 +13,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneColumnImageText from "../../types/component/dynamic-zone/columnImageText"; import type DynamicZoneColumnImageText from "~~/types/component/dynamic-zone/columnImageText";
const runtimeConfig = useRuntimeConfig(); const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url; const baseUrl = runtimeConfig.public.strapi.url;

View file

@ -7,7 +7,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneDualColumnText from "../../types/component/dynamic-zone/dualColumnText"; import type DynamicZoneDualColumnText from "~~/types/component/dynamic-zone/dualColumnText";
defineProps({ defineProps({
data: Object as PropType<DynamicZoneDualColumnText>, data: Object as PropType<DynamicZoneDualColumnText>,

View file

@ -6,7 +6,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneEmbedding from "../../types/component/dynamic-zone/embedding"; import type DynamicZoneEmbedding from "~~/types/component/dynamic-zone/embedding";
const props = defineProps({ const props = defineProps({
data: Object as PropType<DynamicZoneEmbedding>, data: Object as PropType<DynamicZoneEmbedding>,

View file

@ -13,7 +13,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneFileDownload from "../../types/component/dynamic-zone/fileDownload"; import type DynamicZoneFileDownload from "~~/types/component/dynamic-zone/fileDownload";
const runtimeConfig = useRuntimeConfig(); const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url; const baseUrl = runtimeConfig.public.strapi.url;

View file

@ -21,7 +21,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneFileViewer from "../../types/component/dynamic-zone/fileViewer"; import type DynamicZoneFileViewer from "~~/types/component/dynamic-zone/fileViewer";
const runtimeConfig = useRuntimeConfig(); const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url; const baseUrl = runtimeConfig.public.strapi.url;

View file

@ -9,7 +9,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneFullImage from "../../types/component/dynamic-zone/fullImage"; import type DynamicZoneFullImage from "~~/types/component/dynamic-zone/fullImage";
const runtimeConfig = useRuntimeConfig(); const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url; const baseUrl = runtimeConfig.public.strapi.url;

View file

@ -4,7 +4,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneFullText from "../../types/component/dynamic-zone/fullText"; import type DynamicZoneFullText from "~~/types/component/dynamic-zone/fullText";
defineProps({ defineProps({
data: Object as PropType<DynamicZoneFullText>, data: Object as PropType<DynamicZoneFullText>,

View file

@ -12,7 +12,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneGallery from "../../types/component/dynamic-zone/gallery"; import type DynamicZoneGallery from "~~/types/component/dynamic-zone/gallery";
const runtimeConfig = useRuntimeConfig(); const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url; const baseUrl = runtimeConfig.public.strapi.url;

View file

@ -5,7 +5,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneSection from "../../types/component/dynamic-zone/section"; import type DynamicZoneSection from "~~/types/component/dynamic-zone/section";
defineProps({ defineProps({
data: Object as PropType<DynamicZoneSection>, data: Object as PropType<DynamicZoneSection>,

View file

@ -4,7 +4,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type DynamicZoneSpacer from "../../types/component/dynamic-zone/spacer"; import type DynamicZoneSpacer from "~~/types/component/dynamic-zone/spacer";
defineProps({ defineProps({
data: Object as PropType<DynamicZoneSpacer>, data: Object as PropType<DynamicZoneSpacer>,

View file

@ -41,7 +41,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type ContentField from "../../types/field/content"; import type ContentField from "~~/types/field/content";
defineProps({ defineProps({
data: Object as PropType<ContentField>, data: Object as PropType<ContentField>,

View file

@ -13,7 +13,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { TextField } from "../../types/field/content"; import type { TextField } from "~~/types/field/content";
defineProps({ defineProps({
data: Array<TextField>, data: Array<TextField>,

View file

@ -7,7 +7,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type { TypeField } from "../../types/field/content"; import type { TypeField } from "~~/types/field/content";
defineProps({ defineProps({
data: Object as PropType<TypeField>, data: Object as PropType<TypeField>,

View file

@ -15,7 +15,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type ItemsHero from "../../types/component/items/hero"; import type ItemsHero from "~~/types/component/items/hero";
defineProps({ defineProps({
data: Object as PropType<ItemsHero>, data: Object as PropType<ItemsHero>,

View file

@ -21,14 +21,14 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type SharedEmphasiseArticle from "../../types/component/shared/emphasiseArticle"; import type SharedEmphasiseArticle from "~~/types/component/shared/emphasiseArticle";
import type Lookup from "../../types/collection/lookup"; import type Lookup from "~~/types/collection/lookup";
const { find } = useStrapi(); const { find } = useStrapi();
const { data: lookup } = await useAsyncData(() => const { data: lookup } = await useAsyncData(() =>
find<Lookup>("collection-lookups", { find<Lookup>("collection-lookups", {
filters: { filters: {
collection: "articles", collection: { $eq: "articles" },
}, },
}) })
); );

View file

@ -90,8 +90,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PropType } from "vue"; import type { PropType } from "vue";
import type SharedList from "../../types/component/shared/list"; import type SharedList from "~~/types/component/shared/list";
import type BaseCollection from "~/types/collection/baseCollection"; import type BaseCollection from "~~/types/collection/baseCollection";
interface Meta { interface Meta {
page: number; page: number;
@ -113,19 +113,26 @@ const pagination = ref<Meta>({ page: 0, pageSize: 0, pageCount: 0, total: 0 });
const activeYear = ref<number>(0); const activeYear = ref<number>(0);
if (props.data?.lookup.list_with_date != "none") { if (props.data?.lookup.list_with_date != "none") {
const { data: year } = await useAsyncData<Array<number>>(() => const { data: year } = await useAsyncData<Array<number>>(
$fetch(`${baseUrl}/api/custom/${props.data?.lookup.collection}/distinct-years`) "range" + (props.data?.lookup.documentId ?? ""),
() => $fetch(`${baseUrl}/api/custom/${props.data?.lookup.collection}/distinct-years`),
{
watch: [() => props.data],
}
); );
years.value = year.value ?? []; years.value = year.value ?? [];
activeYear.value = years.value[0] ?? 0; activeYear.value = years.value[0] ?? 0;
} }
const { data: collections } = await useAsyncData(() => const { data: collections } = await useAsyncData(
props.data?.lookup.documentId ?? "",
() =>
find<BaseCollection>(props.data?.lookup.collection ?? "", { find<BaseCollection>(props.data?.lookup.collection ?? "", {
...(props.data?.lookup?.list_with_date != "none" ...(props.data?.lookup?.list_with_date != "none"
? { ? {
sort: "date:desc", sort: "date:desc",
filters: { filters: {
date: { date: {
//@ts-ignore
$between: [`${activeYear.value}-01-01 00:00:00.000000`, `${activeYear.value}-12-31 23:59:59.999`], $between: [`${activeYear.value}-01-01 00:00:00.000000`, `${activeYear.value}-12-31 23:59:59.999`],
}, },
}, },
@ -142,7 +149,10 @@ const { data: collections } = await useAsyncData(() =>
withCount: true, withCount: true,
}, },
}), }),
}) }),
{
watch: [() => props.data],
}
); );
collection.value = collections.value?.data; collection.value = collections.value?.data;
pagination.value = (collections.value?.meta.pagination as unknown as { pagination.value = (collections.value?.meta.pagination as unknown as {
@ -226,6 +236,7 @@ async function changeTimedData(year: number) {
sort: "date:desc", sort: "date:desc",
filters: { filters: {
date: { date: {
// @ts-ignore
$between: [`${activeYear.value}-01-01 00:00:00.000000`, `${activeYear.value}-12-31 23:59:59.999`], $between: [`${activeYear.value}-01-01 00:00:00.000000`, `${activeYear.value}-12-31 23:59:59.999`],
}, },
}, },
@ -254,6 +265,7 @@ async function changeTimedPage(page: number = 1) {
sort: "date:desc", sort: "date:desc",
filters: { filters: {
date: { date: {
// @ts-ignore
$between: [`${activeYear.value}-01-01 00:00:00.000000`, `${activeYear.value}-12-31 23:59:59.999`], $between: [`${activeYear.value}-01-01 00:00:00.000000`, `${activeYear.value}-12-31 23:59:59.999`],
}, },
}, },

View file

@ -1,8 +1,8 @@
import type BaseFile from "../types/component/baseFile"; import type BaseFile from "~~/types/component/baseFile";
import type Footer from "../types/component/global/footer"; import type Footer from "~~/types/component/global/footer";
import type Navbar from "../types/component/global/navbar"; import type Navbar from "~~/types/component/global/navbar";
import type SEO from "../types/component/global/seo"; import type SEO from "~~/types/component/global/seo";
import type Global from "../types/single/global"; import type Global from "~~/types/single/global";
export const useGlobal = () => { export const useGlobal = () => {
const global = useState<Global | null>("global"); const global = useState<Global | null>("global");

View file

@ -1,5 +1,5 @@
import type Page from "../types/collection/page"; import type Page from "~~/types/collection/page";
import type { ComponentTypes } from "../types/component/baseComponent"; import type { ComponentTypes } from "~~/types/component/baseComponent";
export const useSitemap = () => { export const useSitemap = () => {
const { navbar, footer } = useGlobal(); const { navbar, footer } = useGlobal();

View file

@ -22,7 +22,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type Homepage from "../types/single/homepage"; import type Homepage from "~~/types/single/homepage";
const runtimeConfig = useRuntimeConfig(); const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url; const baseUrl = runtimeConfig.public.strapi.url;

View file

@ -7,11 +7,11 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type Article from "../types/collection/article"; import type Article from "~~/types/collection/article";
import type Event from "../types/collection/event"; import type Event from "~~/types/collection/event";
import type Operation from "../types/collection/operation"; import type Operation from "~~/types/collection/operation";
import type Vehicle from "../types/collection/vehicle"; import type Vehicle from "~~/types/collection/vehicle";
import type Page from "../types/collection/page"; import type Page from "~~/types/collection/page";
const { const {
params: { slug: params }, params: { slug: params },
@ -33,10 +33,14 @@ const similarestPage = computed(() => {
(bestMatch, current) => { (bestMatch, current) => {
const currentMatchLength = current.path const currentMatchLength = current.path
.split("/") .split("/")
.filter((segment, index) => segment != "" && segment == activePath.value.split("/")[index]).length; .filter(
(segment, index) => segment != "" && segment.trim() == activePath.value.split("/")[index]?.trim()
).length;
const bestMatchLength = bestMatch.path const bestMatchLength = bestMatch.path
.split("/") .split("/")
.filter((segment, index) => segment != "" && segment == activePath.value.split("/")[index]).length; .filter(
(segment, index) => segment != "" && segment.trim() == activePath.value.split("/")[index]?.trim()
).length;
if (currentMatchLength > bestMatchLength) { if (currentMatchLength > bestMatchLength) {
return current; return current;
@ -49,10 +53,10 @@ const similarestPage = computed(() => {
}); });
const { data: pages } = await useAsyncData( const { data: pages } = await useAsyncData(
activePath,
() => () =>
findOne<Page | Array<Page>>("pages", similarestPage.value?.document, { findOne<Page | Array<Page>>("pages", similarestPage.value?.document, {
populate: { populate: {
populate: "*",
content: { content: {
populate: "*", populate: "*",
}, },
@ -60,14 +64,16 @@ const { data: pages } = await useAsyncData(
populate: "*", populate: "*",
}, },
}, },
filters: { filters: !similarestPage.value?.document
...(!similarestPage.value?.document ? {
? { slug: Array.isArray(params) ? params.join("~") : params, ref_only_access: false } slug: { $eq: Array.isArray(params) ? params.join("~") : params ?? "" },
: {}), ref_only_access: { $eq: false },
}, }
: {},
}), }),
{ {
default: () => null, default: () => null,
watch: [activePath],
} }
); );
const page = computed(() => { const page = computed(() => {
@ -83,13 +89,13 @@ const notFound = computed(() => {
else else
return ( return (
!page.value || !page.value ||
(page.value && !(page.value.content.length != 0 || (page.value.hero.title && page.value.hero.banner))) (page.value && !(page.value.content.length != 0 || page.value.hero.title || page.value.hero.banner))
); );
}); });
const showContentBuilder = computed(() => { const showContentBuilder = computed(() => {
if (isCollectionDetail.value && detail.value) return !detail.value; if (isCollectionDetail.value && detail.value) return !detail.value;
else return page.value && (page.value.content.length != 0 || (page.value.hero.title && page.value.hero.banner)); else return page.value && (page.value.content.length != 0 || page.value.hero.title || page.value.hero.banner);
}); });
if (isCollectionDetail) { if (isCollectionDetail) {
@ -103,13 +109,21 @@ if (isCollectionDetail) {
]; ];
for (const element of collectionOfDetail) { for (const element of collectionOfDetail) {
const { data: details } = await useAsyncData(() => const detailKey = `detail-${element}-${activePath.value.substring(activePath.value.lastIndexOf("/") + 1)}`;
const { data: details } = await useAsyncData(
detailKey,
() =>
find<Article | Operation | Event | Vehicle>(element ?? "", { find<Article | Operation | Event | Vehicle>(element ?? "", {
populate: "*", populate: "*",
filters: { filters: {
slug: activePath.value.substring(activePath.value.lastIndexOf("/") + 1), slug: {
$eq: activePath.value.substring(activePath.value.lastIndexOf("/") + 1),
}, },
}) },
}),
{
watch: [activePath],
}
); );
if (details.value?.data[0]) { if (details.value?.data[0]) {
detail.value = details.value?.data[0]; detail.value = details.value?.data[0];

View file

@ -5,7 +5,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type Homepage from "../types/single/homepage"; import type Homepage from "~~/types/single/homepage";
const { findOne } = useStrapi(); const { findOne } = useStrapi();

View file

@ -1,4 +1,4 @@
import type Global from "../types/single/global"; import type Global from "~~/types/single/global";
export default defineNuxtPlugin(async (nuxtApp) => { export default defineNuxtPlugin(async (nuxtApp) => {
const globalState = useState<Global | null>("global", () => null); const globalState = useState<Global | null>("global", () => null);

View file

@ -1,17 +1,25 @@
import type Page from "../types/collection/page"; import type Page from "~~/types/collection/page";
import type Global from "../types/single/global"; import type Global from "~~/types/single/global";
export default defineNuxtPlugin(async (nuxtApp) => { export default defineNuxtPlugin(async (nuxtApp) => {
const pageState = useState<Page[]>("sitemap_pages", () => []); const pageState = useState<Page[]>("sitemap_pages", () => []);
if (!pageState.value) { if (pageState.value.length == 0) {
const { find } = useStrapi(); const { find } = useStrapi();
const { data: page_res } = await useAsyncData( const { data: page_res } = await useAsyncData(
"sitemap_pages", "sitemap_pages",
() => () =>
find<Page>("pages", { find<Page>("pages", {
filters: { filters: {
ref_only_access: false, //@ts-ignore
$or: [
{
ref_only_access: { $eq: false },
},
{
ref_only_access: { $null: true },
},
],
}, },
}), }),
{ {

View file

@ -18,6 +18,8 @@ export default defineNuxtConfig({
}, },
}, },
ssr: true,
css: ["~/assets/app.css", "~/assets/ConthraxSemiBold.css"], css: ["~/assets/app.css", "~/assets/ConthraxSemiBold.css"],
compatibilityDate: "2024-04-03", compatibilityDate: "2024-04-03",

9853
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -12,14 +12,14 @@
"postinstall": "nuxt prepare" "postinstall": "nuxt prepare"
}, },
"dependencies": { "dependencies": {
"@nuxt/image": "^1.8.1", "@nuxt/image": "^1.10.0",
"@nuxtjs/strapi": "^2.0.0", "@nuxtjs/strapi": "^2.1.1",
"@tailwindcss/vite": "^4.1.4", "@tailwindcss/vite": "^4.1.11",
"nuxt": "^3.16.2", "nuxt": "^4.0.1",
"vue": "latest", "vue": "latest",
"vue-router": "latest" "vue-router": "latest"
}, },
"devDependencies": { "devDependencies": {
"tailwindcss": "^4.1.4" "tailwindcss": "^4.1.11"
} }
} }

View file

@ -12,5 +12,6 @@ export default interface Page {
slug: string; slug: string;
hero: ItemsHero; hero: ItemsHero;
content: Array<ComponentTypes>; content: Array<ComponentTypes>;
ref_only_access: boolean;
localizations: any[]; localizations: any[];
} }