From 6d3985f632add6437a13ef449dff5d1e8391fffc Mon Sep 17 00:00:00 2001 From: mirumi Date: Sun, 9 Jun 2024 17:47:03 +0900 Subject: [PATCH 1/2] fix: remove hack code for gomi server --- src/pages/[post].vue | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/pages/[post].vue b/src/pages/[post].vue index 8d768c5..f1b4f53 100644 --- a/src/pages/[post].vue +++ b/src/pages/[post].vue @@ -110,25 +110,13 @@ onMounted(async () => { const slug = route.params.post as string +const { data } = await useFetch(`/mirumi/post_data/${slug}`, { + baseURL: appConfig.baseURL, + retry: 100, + retryDelay: 10_000, +}) // biome-ignore lint: -let post: any = undefined -do { - post = undefined - - const { data } = await useFetch(`/mirumi/post_data/${slug}`, { - baseURL: appConfig.baseURL, - retry: 100, - retryDelay: 10_000, - }) - - // biome-ignore lint: Hack for JSON parse error (unexpected token) - post = JSON.parse(JSON.stringify(data.value as any)) - - if (typeof post === "string") { - console.log(`Failed to fetch: /${slug}`) - await delay(10_000) - } -} while (typeof post === "string") +const post = data.value as any const thumbnailUrl = post.thumbnail_url.replace(/\.(png|jpg|jpeg)$/gim, ".webp") From 94ba70e9104a6fc2efacf508adc31e448af78ba4 Mon Sep 17 00:00:00 2001 From: mirumi Date: Mon, 10 Jun 2024 18:33:19 +0900 Subject: [PATCH 2/2] fix: current category highlight --- biome.json | 3 +- src/components/modules/TheCategoryMenu.vue | 79 +++++++++++++++------- 2 files changed, 58 insertions(+), 24 deletions(-) diff --git a/biome.json b/biome.json index 3b3bf7c..2bb7cf9 100644 --- a/biome.json +++ b/biome.json @@ -13,7 +13,8 @@ "useTemplate": "off", "noUselessElse": "off", "useImportType": "off", - "noUnusedTemplateLiteral": "off" + "noUnusedTemplateLiteral": "off", + "useShorthandFunctionType": "off" }, "complexity": { "noForEach": "off" diff --git a/src/components/modules/TheCategoryMenu.vue b/src/components/modules/TheCategoryMenu.vue index fc91799..00a62c0 100644 --- a/src/components/modules/TheCategoryMenu.vue +++ b/src/components/modules/TheCategoryMenu.vue @@ -2,25 +2,47 @@
    -
  • -
    +
  • +
    - + {{ category.name }} - +
    • - + {{ other.name }}
    - + {{ category.name }}
  • @@ -44,7 +66,7 @@ const p = defineProps<{ }>() const emit = defineEmits<{ - (e: "interruptChoose" ): void + (e: "interruptChoose"): void }>() const route = useRoute() @@ -73,13 +95,19 @@ const others: Category[] = [ await setIsCurrentCategory() -watch(() => p.isShown, () => { - _isShown.value = p.isShown -}) +watch( + () => p.isShown, + () => { + _isShown.value = p.isShown + } +) -watch(route, async () => { - await setIsCurrentCategory() -}) +watch( + () => route.path, + async () => { + await setIsCurrentCategory() + } +) async function setIsCurrentCategory(): Promise { let categorySlug = "" @@ -87,17 +115,20 @@ async function setIsCurrentCategory(): Promise { if (route.params.categoryName) { // In category page - categorySlug = route.path.replace("/category/", "") + categorySlug = route.path.replace(/\/category\/(.*?)\//gim, "$1") } else if (route.params.post) { // In post page - const pagePath = route.path.replace("/", "") - - // https://github.com/nuxt/nuxt/discussions/??? (The page is gone... (cause by unifying repos for Nuxt 2/3)) - categorySlug = await $fetch(`/mirumi/category_slug_with_post_slug/${pagePath}`, { - baseURL: appConfig.baseURL, - parseResponse: JSON.parse, - }) + const pagePath = route.path.replaceAll("/", "") + + // https://github.com/nuxt/nuxt/discussions/??? (The page is gone... (cause by unifying repos for Nuxt 2~3)) + categorySlug = await $fetch( + `/mirumi/category_slug_with_post_slug/${pagePath}`, + { + baseURL: appConfig.baseURL, + parseResponse: JSON.parse, + } + ) } for (const category of categories) { @@ -111,7 +142,7 @@ async function setIsCurrentCategory(): Promise { for (const other of others) { if (categorySlug === other.slug) { other.current = true - categories.slice(-1)[0].current = true // `その他` + categories.slice(-1)[0].current = true // `その他` } else { other.current = false } @@ -175,7 +206,9 @@ const interruptChoose = () => { } } } - a, span, .others_wrap > .others_title > span { + a, + span, + .others_wrap > .others_title > span { display: block; color: var(--color-gray); text-decoration: none;