-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Prettier config and ignore .idea
- Loading branch information
1 parent
04da4aa
commit c26fe2d
Showing
14 changed files
with
208 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ node_modules | |
.data | ||
.env | ||
dist | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"vueIndentScriptAndStyle": true, | ||
"trailingComma": "all", | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,68 @@ | ||
<script setup lang="ts"> | ||
import type { Toc } from "@nuxt/content/types"; | ||
import type { Toc } from '@nuxt/content/types' | ||
const props = defineProps<{ toc: Toc | undefined }>(); | ||
const props = defineProps<{ toc: Toc | undefined }>() | ||
const activeLink = ref(""); | ||
const activeLink = ref('') | ||
onMounted(() => { | ||
const articleElement: HTMLElement | undefined = | ||
document.getElementsByTagName("article")[0]; | ||
onMounted(() => { | ||
const articleElement: HTMLElement | undefined = document.getElementsByTagName('article')[0] | ||
if (articleElement?.firstElementChild) { | ||
const observedElements: Map<Element, [string, boolean]> = new Map(); | ||
if (articleElement?.firstElementChild) { | ||
const observedElements: Map<Element, [string, boolean]> = new Map() | ||
const observer = new IntersectionObserver( | ||
(entries) => { | ||
for (const entry of entries) { | ||
const target = observedElements.get(entry.target); | ||
if (target) { | ||
target[1] = entry.isIntersecting; | ||
const observer = new IntersectionObserver( | ||
(entries) => { | ||
for (const entry of entries) { | ||
const target = observedElements.get(entry.target) | ||
if (target) { | ||
target[1] = entry.isIntersecting | ||
} | ||
} | ||
} | ||
for (const element of observedElements.values()) { | ||
if (element[1]) { | ||
activeLink.value = element[0]; | ||
break; | ||
for (const element of observedElements.values()) { | ||
if (element[1]) { | ||
activeLink.value = element[0] | ||
break | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
rootMargin: "-60px 0px 0px 0px", | ||
threshold: [0, 1], | ||
} | ||
); | ||
}, | ||
{ | ||
rootMargin: '-60px 0px 0px 0px', | ||
threshold: [0, 1], | ||
}, | ||
) | ||
let currentId = ""; | ||
for (const element of articleElement.firstElementChild.children) { | ||
switch (element.tagName) { | ||
case "H2": | ||
case "H3": | ||
currentId = element.id; | ||
} | ||
if (currentId) { | ||
observedElements.set(element, [currentId, false]); | ||
observer.observe(element); | ||
let currentId = '' | ||
for (const element of articleElement.firstElementChild.children) { | ||
switch (element.tagName) { | ||
case 'H2': | ||
case 'H3': | ||
currentId = element.id | ||
} | ||
if (currentId) { | ||
observedElements.set(element, [currentId, false]) | ||
observer.observe(element) | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
}) | ||
</script> | ||
|
||
<template> | ||
<v-list class="pt-0"> | ||
<v-list-item subtitle="Contents" /> | ||
<v-divider /> | ||
<template v-if="props.toc" v-for="h2 in props.toc.links" :key="h2.id"> | ||
<v-list-item | ||
density="compact" | ||
:to="`#${h2.id}`" | ||
:title="h2.text" | ||
:active="activeLink === h2.id" | ||
/> | ||
<v-list-item density="compact" :to="`#${h2.id}`" :title="h2.text" :active="activeLink === h2.id" /> | ||
<template v-for="h3 in h2.children" :key="h3.id"> | ||
<v-list-item | ||
:to="`#${h3.id}`" | ||
:subtitle="h3.text" | ||
:active="activeLink === h3.id" | ||
class="ps-8 tiny" | ||
/> | ||
<v-list-item :to="`#${h3.id}`" :subtitle="h3.text" :active="activeLink === h3.id" class="ps-8 tiny" /> | ||
</template> | ||
</template> | ||
</v-list> | ||
</template> | ||
|
||
<style> | ||
.tiny { | ||
min-height: 32px !important; | ||
} | ||
.tiny { | ||
min-height: 32px !important; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
export default function () { | ||
const { path } = useRoute(); | ||
const { data, error } = useAsyncData( | ||
`content-${path}`, | ||
() => queryContent(path).findOne(), | ||
{ | ||
deep: false, | ||
} | ||
); | ||
const { path } = useRoute() | ||
const { data, error } = useAsyncData(`content-${path}`, () => queryContent(path).findOne(), { | ||
deep: false, | ||
}) | ||
|
||
watchEffect(() => { | ||
if (error.value) throw error.value; | ||
}); | ||
if (error.value) throw error.value | ||
}) | ||
|
||
return data; | ||
return data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.