Skip to content

Commit

Permalink
feat: control edit link via front matter
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <[email protected]>
  • Loading branch information
ZTL-UwU committed Nov 11, 2024
1 parent ded42e7 commit 52d53c1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
8 changes: 1 addition & 7 deletions components/layout/DocsFooter.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<template>
<div class="mt-16">
<div v-if="editLink.enable" class="mb-6 flex justify-between">
<LayoutEditLink />
</div>
<LayoutEditLink />
<LayoutPrevNext />
</div>
</template>

<script setup lang="ts">
const { editLink } = useConfig().value.main;
</script>
6 changes: 4 additions & 2 deletions components/layout/EditLink.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<div>
<div
v-if="enable && page.editLink !== false && page._file && url !== ''"
class="mb-6 w-fit"
>
<NuxtLink
v-if="enable && page._file && url !== ''"
:to="url"
target="_blank"
class="text-sm font-semibold text-primary"
Expand Down
3 changes: 3 additions & 0 deletions content/1.getting-started/3.writing/2.pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ badges:
::field{name="toc" type="boolean" default-value="true"}
Whether to show the toc section for this page.
::
::field{name="editLink" type="boolean" default-value="true"}
Whether to show the edit link for this page.
::
::
10 changes: 10 additions & 0 deletions content/3.api/1.configuration/5.edit-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ export default defineAppConfig({

- The `icon` option allows you to customize the icon (default is `lucide:square-pen`)

### Front Matter

The edit link can be disabled per-page using the `editLink` option in front matter.

```yaml
---
editLink: false
---
```

## Parameters

::field-group
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default defineNuxtConfig({
'toc',
'sidebar',
'collapse',
'editLink',
],
},
experimental: {
Expand Down

0 comments on commit 52d53c1

Please sign in to comment.