Skip to content

Commit 84f8bc8

Browse files
committed
Updated: replaced internal plugin by its external implementation
1 parent 4e7537b commit 84f8bc8

13 files changed

+117
-219
lines changed

app.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ useHead({
66
titleTemplate: '%s - Helltraitor',
77
})
88
9-
useNuxtApp().$anchorScroll = {
9+
useNuxtApp().$anchorScroll!.defaults.toAnchor = () => ({
1010
behavior: 'smooth',
1111
// headerHeight + 20%
12-
offsetTop: computed(() => -toValue(useNuxtApp().$headerHeight ?? 0) * 1.2),
13-
}
12+
offsetTop: -toValue(useNuxtApp().$headerHeight ?? 0) * 1.2,
13+
})
1414
</script>
1515

1616
<template>

components/content/ProseH1.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ANCHOR_LINK_LEVEL = 1
1212
const { depth: anchorDepth, exclude: anchorExcluded } = runtimeConfig.public.content.anchorLinks
1313
const anchorLinkEnabled = ANCHOR_LINK_LEVEL <= anchorDepth && !anchorExcluded.includes(ANCHOR_LINK_LEVEL)
1414
15-
const { scrollToAnchor } = useAnchorScroll(useNuxtApp().$anchorScroll)
15+
const { scrollToAnchor } = useAnchorScroll()
1616
</script>
1717

1818
<template>

components/content/ProseH2.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ANCHOR_LINK_LEVEL = 2
1212
const { depth: anchorDepth, exclude: anchorExcluded } = runtimeConfig.public.content.anchorLinks
1313
const anchorLinkEnabled = ANCHOR_LINK_LEVEL <= anchorDepth && !anchorExcluded.includes(ANCHOR_LINK_LEVEL)
1414
15-
const { scrollToAnchor } = useAnchorScroll(useNuxtApp().$anchorScroll)
15+
const { scrollToAnchor } = useAnchorScroll()
1616
</script>
1717

1818
<template>

components/content/ProseH3.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ANCHOR_LINK_LEVEL = 3
1212
const { depth: anchorDepth, exclude: anchorExcluded } = runtimeConfig.public.content.anchorLinks
1313
const anchorLinkEnabled = ANCHOR_LINK_LEVEL <= anchorDepth && !anchorExcluded.includes(ANCHOR_LINK_LEVEL)
1414
15-
const { scrollToAnchor } = useAnchorScroll(useNuxtApp().$anchorScroll)
15+
const { scrollToAnchor } = useAnchorScroll()
1616
</script>
1717

1818
<template>

components/content/ProseH4.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ANCHOR_LINK_LEVEL = 4
1212
const { depth: anchorDepth, exclude: anchorExcluded } = runtimeConfig.public.content.anchorLinks
1313
const anchorLinkEnabled = ANCHOR_LINK_LEVEL <= anchorDepth && !anchorExcluded.includes(ANCHOR_LINK_LEVEL)
1414
15-
const { scrollToAnchor } = useAnchorScroll(useNuxtApp().$anchorScroll)
15+
const { scrollToAnchor } = useAnchorScroll()
1616
</script>
1717

1818
<template>

components/content/ProseH5.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ANCHOR_LINK_LEVEL = 5
1212
const { depth: anchorDepth, exclude: anchorExcluded } = runtimeConfig.public.content.anchorLinks
1313
const anchorLinkEnabled = ANCHOR_LINK_LEVEL <= anchorDepth && !anchorExcluded.includes(ANCHOR_LINK_LEVEL)
1414
15-
const { scrollToAnchor } = useAnchorScroll(useNuxtApp().$anchorScroll)
15+
const { scrollToAnchor } = useAnchorScroll()
1616
</script>
1717

1818
<template>

components/content/ProseH6.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ANCHOR_LINK_LEVEL = 6
1212
const { depth: anchorDepth, exclude: anchorExcluded } = runtimeConfig.public.content.anchorLinks
1313
const anchorLinkEnabled = ANCHOR_LINK_LEVEL <= anchorDepth && !anchorExcluded.includes(ANCHOR_LINK_LEVEL)
1414
15-
const { scrollToAnchor } = useAnchorScroll(useNuxtApp().$anchorScroll)
15+
const { scrollToAnchor } = useAnchorScroll()
1616
</script>
1717

1818
<template>

composables/anchorscroll.ts

-113
This file was deleted.

nuxt.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default defineNuxtConfig({
2222
'@nuxt/content',
2323
'@unocss/nuxt',
2424
'@vueuse/nuxt',
25+
'nuxt-anchorscroll',
2526
],
2627
runtimeConfig: {
2728
public: {

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@vueuse/nuxt": "^10.2.1",
2424
"eslint": "^8.43.0",
2525
"nuxt": "^3.6.0",
26+
"nuxt-anchorscroll": "^1.0.0",
2627
"nuxt-content-assets": "^1.3.2",
2728
"remark-heading-id": "^1.0.0",
2829
"sass": "^1.63.6",

plugins/anchorscroll.client.ts

-53
This file was deleted.

plugins/anchorscroll.d.ts

-44
This file was deleted.

0 commit comments

Comments
 (0)