Skip to content

Commit

Permalink
chore: modified all links to nuxt-i18n convention
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviareichl committed Jan 9, 2024
1 parent 0e5df77 commit 28b61cb
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 7 deletions.
6 changes: 4 additions & 2 deletions components/Entity/DetailCard.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script setup lang="ts">
import type { DetailItem } from "~~/types/entityDetailTypes";
const localePath = useLocalePath();
const props = defineProps({
title: {
type: String,
Expand Down Expand Up @@ -37,7 +39,7 @@ const showExpandable = computed(() => {
<VDivider v-if="index > 0" />
<p>
<b v-if="item?.subheader">{{ item?.subheader }}:</b>
<NuxtLink :to="`/entity/${item?.id}`">{{ item.label }}</NuxtLink>
<NuxtLink :to="localePath(`/entity/${item?.id}`)">{{ item.label }}</NuxtLink>
</p>
</span>
</template>
Expand All @@ -54,7 +56,7 @@ const showExpandable = computed(() => {
<VDivider />
<p>
<b v-if="item?.subheader">{{ item?.subheader }}:</b>
<NuxtLink :to="`/entity/${item?.id}`">
<NuxtLink :to="localePath(`/entity/${item?.id}`)">
{{ item.label }}
</NuxtLink>
</p>
Expand Down
3 changes: 2 additions & 1 deletion components/Entity/MapContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface EntityMapContainerProps {
bounds?: SizeBounds;
}
const localePath = useLocalePath();
const props = defineProps<EntityMapContainerProps>();
</script>

Expand All @@ -25,7 +26,7 @@ const props = defineProps<EntityMapContainerProps>();
/>
<VCardActions justify="center">
<VSpacer />
<VBtn to="/map" prepend-icon="mdi-map-marker">
<VBtn :to="localePath('/map')" prepend-icon="mdi-map-marker">
{{ $t("global.basics.map") }}
</VBtn>
<VSpacer />
Expand Down
31 changes: 31 additions & 0 deletions components/content/ProseA.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { isUrl } from "@acdh-oeaw/lib";
const localePath = useLocalePath();
const props = defineProps<{
href: string;
target?: "_blank";
}>();
const isExternalUrl = computed(() => {
return isUrl(props.href);
});
const href = computed(() => {
if (isExternalUrl.value) return props.href;
return localePath(props.href);
});
const target = computed(() => {
if (props.target != null) return props.target;
if (isExternalUrl.value) return "_blank";
return undefined;
});
</script>

<template>
<NuxtLink :href="href" :target="target">
<slot />
</NuxtLink>
</template>
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"types:check": "nuxt typecheck"
},
"dependencies": {
"@acdh-oeaw/lib": "^0.1.6",
"@mdi/font": "^7.3.67",
"@nuxt/content": "2.8.2",
"@nuxt/image": "^1.1.0",
Expand Down
8 changes: 6 additions & 2 deletions pages/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<script setup lang="ts">
const localePath = useLocalePath();
</script>

<template>
<VSheet height="calc(100vh - 65px)" class="d-flex justify-center pt-5">
<VContainer class="text-center" data-test="main-content-renderer">
<ContentDoc>
<template #not-found>
<h1>Document not found</h1>
<NuxtLink to="/">{{ $t("global.basics.backHome") }}.</NuxtLink>
<NuxtLink :to="localePath('/')">{{ $t("global.basics.backHome") }}.</NuxtLink>
</template>
<template #empty>
<h1>Document is empty</h1>
<NuxtLink to="/">{{ $t("global.basics.backHome") }}.</NuxtLink>
<NuxtLink :to="localePath('/')">{{ $t("global.basics.backHome") }}.</NuxtLink>
</template>
</ContentDoc>
</VContainer>
Expand Down
3 changes: 2 additions & 1 deletion pages/data/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { Query } from "~~/types/query";
const { t } = useI18n();
const { $api } = useNuxtApp();
const localePath = useLocalePath();
definePageMeta({
middleware: ["api"],
Expand Down Expand Up @@ -74,7 +75,7 @@ function updateQuery(newQuery: Query) {
</VTooltip>
</template>
<template #features[0].properties.title="{ item, value }">
<NuxtLink :to="`/entity/${item.features[0]['@id'].split('/').at(-1)}`">
<NuxtLink :to="localePath(`/entity/${item.features[0]['@id'].split('/').at(-1)}`)">
{{ value }}
</NuxtLink>
</template>
Expand Down
3 changes: 2 additions & 1 deletion pages/map/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { Format, Query, ViewClasses } from "~~/types/query";
const { $api } = useNuxtApp();
const localePath = useLocalePath();
const { t } = useI18n();
definePageMeta({
Expand Down Expand Up @@ -109,7 +110,7 @@ function updateQuery(newQuery: Query) {
style="max-height: 400px"
/>
<VCardActions>
<VBtn :to="`/entity/${featureContent.id}`" variant="text">
<VBtn :to="localePath(`/entity/${featureContent.id}`)" variant="text">
{{ $t("global.basics.more details") }}
</VBtn>
</VCardActions>
Expand Down

0 comments on commit 28b61cb

Please sign in to comment.