Skip to content

Commit

Permalink
feat: add a link to discussion thread (#86)
Browse files Browse the repository at this point in the history
* feat: add a link to discussion thread

* Update components/PanelDocs.vue

Co-authored-by: ubugeeei <[email protected]>

* Update components/PanelDocs.vue

Co-authored-by: ubugeeei <[email protected]>

* Update components/PanelDocs.vue

Co-authored-by: ubugeeei <[email protected]>

* fix: type errors

* chore

---------

Co-authored-by: ubugeeei <[email protected]>
Co-authored-by: Ubugeeei <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent 3c39d7c commit 65fbf9a
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion components/PanelDocs.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- eslint-disable vue/return-in-computed-property -->
<script setup lang="ts">
import type { NavItem, ParsedContent } from '@nuxt/content'
Expand Down Expand Up @@ -63,6 +64,32 @@ const sourceUrl = computed(() =>
: undefined,
)
// NOTE: remove when hands-on finished (will be held on 2024-10-19)
const THREAD_ID_MAP: Readonly<Record<string, number>> = {
'0.index.md': 85,
'1.vue/1.index.md': 68,
'1.vue/2.reactivity/index.md': 71,
'1.vue/3.reactivity-2/index.md': 72,
'1.vue/4.composition-api/index.md': 73,
'1.vue/5.components/index.md': 74,
'1.vue/6.summary/index.md': 75,
'2.concepts/1.index.md': 76,
'2.concepts/2.app-vue/index.md': 77,
'2.concepts/3.routing/index.md': 78,
'2.concepts/4.auto-imports/index.md': 79,
'2.concepts/5.middleware/index.md': 80,
'2.concepts/6.layout/index.md': 81,
'2.concepts/7.rendering-modes/index.md': 82,
'2.concepts/8.state-manegement/index.md': 83,
'2.concepts/9.data-fetching/index.md': 84,
}
const threadUrl = computed<string | null>(() =>
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<HTMLElement | null>(null)
const router = useRouter()
router.beforeEach(() => {
Expand Down Expand Up @@ -118,7 +145,7 @@ router.beforeEach(() => {
/>
</div>
</div>
<div border="t base dashed" mt-8 p3>
<div flex="~ items-center gap-4" border="t base dashed" mt-8 p3>
<NuxtLink
v-if="sourceUrl"
:to="sourceUrl" target="_blank"
Expand All @@ -129,6 +156,17 @@ router.beforeEach(() => {
<div i-ph-note-pencil-duotone />
Edit this page
</NuxtLink>
<NuxtLink
v-if="threadUrl"
:to="threadUrl"
target="_blank"
flex="~ items-center gap-2"
text-inherit op75
hover="text-primary op100"
>
<div i-ph-arrow-square-out-fill />
Ask your question
</NuxtLink>
</div>
</article>
<!-- Navigration Dropdown -->
Expand Down

0 comments on commit 65fbf9a

Please sign in to comment.