diff --git a/components/PanelDocs.vue b/components/PanelDocs.vue index 6345312..17b30a8 100644 --- a/components/PanelDocs.vue +++ b/components/PanelDocs.vue @@ -65,7 +65,7 @@ const sourceUrl = computed(() => ) // NOTE: remove when hands-on finished (will be held on 2024-10-19) -const THREAD_ID_MAP = { +const THREAD_ID_MAP: Readonly> = { '0.index.md': 85, '1.vue/1.index.md': 68, '1.vue/2.reactivity/index.md': 71, @@ -82,15 +82,12 @@ const THREAD_ID_MAP = { '2.concepts/7.rendering-modes/index.md': 82, '2.concepts/8.state-manegement/index.md': 83, '2.concepts/9.data-fetching/index.md': 84, -} as const satisfies Record - -type ThreadIdMapKey = keyof typeof THREAD_ID_MAP +} -const threadUrl = computed(() => { - if (page.value?._file) { - const threadId = THREAD_ID_MAP[page.value._file as ThreadIdMapKey] - return `https://github.com/vuejs-jp/learn.nuxt.com/discussions/${threadId}` - } +const threadUrl = computed(() => { + return page.value?._file && THREAD_ID_MAP[page.value._file] + ? `https://github.com/vuejs-jp/learn.nuxt.com/discussions/${THREAD_ID_MAP[page.value._file]}` + : null }) const docsEl = ref(null)