-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: set Prev/Next to page data * feat: set links at the bottom of page * feat: hide next/prev links when themeConfig expressly set false
- Loading branch information
Showing
5 changed files
with
97 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { defineComponent, computed } from 'vue' | ||
import { usePageData } from 'vitepress' | ||
|
||
export default defineComponent({ | ||
setup() { | ||
const pageData = usePageData() | ||
const next = computed(() => { | ||
return pageData.value.next | ||
}) | ||
const prev = computed(() => { | ||
return pageData.value.prev | ||
}) | ||
const hasLinks = computed(() => { | ||
return !!next || !!prev | ||
}) | ||
return { | ||
next, | ||
prev, | ||
hasLinks | ||
} | ||
} | ||
}) |
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,25 @@ | ||
<template> | ||
<div v-if="hasLinks" class="links-wrapper"> | ||
<div class="prev-link"> | ||
<div v-if="prev"> | ||
← <a :href="prev.link">{{prev.text}}</a> | ||
</div> | ||
</div> | ||
<div class="next-link"> | ||
<div v-if="next"> | ||
<a :href="next.link">{{next.text}}</a> → | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script src="./NextAndPrevLinks"></script> | ||
|
||
<style> | ||
.links-wrapper { | ||
padding-top: 1rem; | ||
padding-bottom: 1rem; | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
</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
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