From 8f9fdfe64381e640133077175924f239813d1b30 Mon Sep 17 00:00:00 2001 From: Remi PLANEL <rplanel@pasteur.fr> Date: Thu, 5 Oct 2023 20:32:40 +0200 Subject: [PATCH] no need to refine with to attribute --- Dockerfile | 2 ++ components/Nav/Navbar.vue | 24 ++++++++++++------------ composables/useRefinedUrl.ts | 4 ++++ docker-compose.yml | 2 ++ pages/defense-systems.vue | 2 ++ 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index b7e87c1c..2420a62e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,9 @@ RUN npm install ### STAGE: Dev FROM node:19.5-bullseye-slim as dev +ARG BASE_URL=/ +ENV NUXT_APP_BASE_URL=${BASE_URL} WORKDIR /usr/src/app COPY --from=install /usr/src/app ./ COPY . /usr/src/app diff --git a/components/Nav/Navbar.vue b/components/Nav/Navbar.vue index 9b0dc3f1..281ba3bf 100644 --- a/components/Nav/Navbar.vue +++ b/components/Nav/Navbar.vue @@ -27,20 +27,20 @@ const sections = ref([ ]); -const computedSections = computed(() => { - return sections.value.map(section => { +// const computedSections = computed(() => { +// return sections.value.map(section => { - if (section?.to) { - const { refinedUrl } = useRefinedUrl(section.to) - return { ...section, to: refinedUrl.value } - } - else { - return section - } +// if (section?.to) { +// const { refinedUrl } = useRefinedUrl(section.to) +// return { ...section, to: refinedUrl.value } +// } +// else { +// return section +// } - }) -}) +// }) +// }) const drawer = ref(true); @@ -76,7 +76,7 @@ const computedNavigation = computed(() => { </span> </v-app-bar-title> <template #append v-if="!mobile"> - <v-btn v-for="section in computedSections" :key="section.id" color="primary" :to="section?.to ?? null" + <v-btn v-for="section in sections" :key="section.id" color="primary" :to="section?.to ?? null" :href="section?.href ?? null" exact> {{ section.label }} </v-btn> diff --git a/composables/useRefinedUrl.ts b/composables/useRefinedUrl.ts index bd679334..3e81d7c3 100644 --- a/composables/useRefinedUrl.ts +++ b/composables/useRefinedUrl.ts @@ -1,13 +1,17 @@ +import { join } from "path"; import { withTrailingSlash, withLeadingSlash, joinURL } from "ufo"; export function useRefinedUrl(url: string | Ref<string>) { + console.log(useRuntimeConfig().app.baseURL) const refinedUrl = computed(() => { const sanitzedUrl = toValue(url) + if (sanitzedUrl.startsWith("/") && !sanitzedUrl.startsWith("//")) { const _base = withLeadingSlash( withTrailingSlash(useRuntimeConfig().app.baseURL) ); + console.log(_base) if (_base !== "/" && !sanitzedUrl.startsWith(_base)) { return joinURL(_base, sanitzedUrl); } diff --git a/docker-compose.yml b/docker-compose.yml index db77b855..972dd12a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,8 @@ services: build: context: . target: dev + args: + BASE_URL: /wiki/ container_name: nuxt environment: HOST: 0.0.0.0 diff --git a/pages/defense-systems.vue b/pages/defense-systems.vue index 14f690ee..c455cf83 100644 --- a/pages/defense-systems.vue +++ b/pages/defense-systems.vue @@ -48,6 +48,8 @@ const systems = computed(() => { }; }); }); + + </script> <template> <v-card flat color="transparent"> -- GitLab