diff --git a/components/PostItem.vue b/components/PostItem.vue index eb9ead1..8a488fb 100644 --- a/components/PostItem.vue +++ b/components/PostItem.vue @@ -1,5 +1,5 @@ @@ -17,13 +18,9 @@ definePageMeta({ const { t } = useI18n() const route = useRoute() +const config = useRuntimeConfig() -if(Number.isNaN(parseInt(route.params.id?.toString()))) { - throw createError({ - statusCode: 400, - statusMessage: "Realm ID must be a Number", - }) -} +const { data: publisher } = useFetch(`${config.public.solarNetworkApi}/cgi/co/publishers/${route.params.id}`) useHead({ title: t("navPosts"), diff --git a/pages/index.vue b/pages/index.vue index a1737ce..81e4cb4 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -71,7 +71,7 @@ const { data: products } = await useAsyncData("products", () => { } .content-section { - height: calc(100vh - 80px); + min-height: calc(100vh - 80px); display: flex; place-items: center; } diff --git a/pages/posts/[id].vue b/pages/posts/[id].vue index 9181745..e848fac 100644 --- a/pages/posts/[id].vue +++ b/pages/posts/[id].vue @@ -93,10 +93,17 @@ const { t } = useI18n() const { data: post } = await useFetch(`${config.public.solarNetworkApi}/cgi/co/posts/${slug.value}`) if (!post.value) { + const { data: publisher } = await $fetch(`${config.public.solarNetworkApi}/cgi/co/publishers/${route.params.id}`) + if (publisher) { + navigateTo(`/posts/publishers/${route.params.id}`) + } + throw createError({ statusCode: 404, statusMessage: "Post Not Found", }) +} else if (post.value.alias) { + navigateTo(`/posts/${post.value.area_alias}/${post.value.alias}`) } const title = computed(() => post.value.body?.title ? `${post.value.body?.title} from ${post.value.author.nick}` : `Post from ${post.value.author.nick}`) diff --git a/pages/posts/realms/[id].vue b/pages/posts/publishers/[id].vue similarity index 59% rename from pages/posts/realms/[id].vue rename to pages/posts/publishers/[id].vue index bde1a83..dcea6c3 100644 --- a/pages/posts/realms/[id].vue +++ b/pages/posts/publishers/[id].vue @@ -2,10 +2,11 @@

{{ t("navPosts") }}

- {{ t("navPostsCaptionWithRealm", [`#${route.params.id}`]) }} + {{ t("navPostsCaptionWithPublisher", [publisher.data.name]) }}
- + +
@@ -13,13 +14,9 @@ const { t } = useI18n() const route = useRoute() +const config = useRuntimeConfig() -if(Number.isNaN(parseInt(route.params.id?.toString()))) { - throw createError({ - statusCode: 400, - statusMessage: "Realm ID must be a Number", - }) -} +const { data: publisher } = useFetch(`${config.public.solarNetworkApi}/cgi/co/publishers/${route.params.id}`) useHead({ title: t("navPosts"),