From f0671746b6881579df147ca22f753e9d19668a19 Mon Sep 17 00:00:00 2001 From: Barbapapazes Date: Wed, 25 Jan 2023 03:15:13 +0100 Subject: [PATCH] feat: add edit on github (#767) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Yaël GUILLOUX fix https://github.com/nuxt-themes/docus/issues/756 --- .docs/.studio/app.config.json | 7 +++ .../content/1.introduction/4.configuration.md | 7 ++- .playground/app.config.ts | 12 +++- .playground/content/0.index.md | 2 - app.config.ts | 11 ++++ components/app/AppLayout.vue | 14 ++--- components/docs/DocsPageBottom.vue | 19 +++++-- components/docs/DocsPageLayout.vue | 3 +- components/docs/EditOnLink.vue | 12 ++-- nuxt.schema.ts | 55 ++++++++++++++++++- 10 files changed, 114 insertions(+), 28 deletions(-) diff --git a/.docs/.studio/app.config.json b/.docs/.studio/app.config.json index c769c4167..328beaaa4 100644 --- a/.docs/.studio/app.config.json +++ b/.docs/.studio/app.config.json @@ -26,6 +26,13 @@ "lg": true } }, + "github": { + "dir": ".docs/content", + "branch": "dev", + "repo": "docus", + "owner": "nuxt-themes", + "edit": true + }, "footer": { "credits": { "icon": "IconDocus", diff --git a/.docs/content/1.introduction/4.configuration.md b/.docs/content/1.introduction/4.configuration.md index 04a34c053..e416181df 100644 --- a/.docs/content/1.introduction/4.configuration.md +++ b/.docs/content/1.introduction/4.configuration.md @@ -78,6 +78,7 @@ export default defineAppConfig({ | **Key** | **Type** | **Default** | **Description** | | ---------------------------- | ---------- | ---------------- | ------------------------------------------------------------------- | | `title` | `string` | Docus | Website title | +| `titleTemplate` | `string` | Docus | Website title template | | `description` | `string` | My Docus Project | Website description | | `url` | `string` | | Website URL | | `layout` | `string` | default | Fallback layout to use | @@ -122,6 +123,8 @@ export default defineAppConfig({ | `footer.iconLinks[0].icon` | `string` | | The icon to use (can be a component name) | | **GitHub** | | | | | `github` | `object` | `false` | GitHub integration configuration | +| `github.dir` | `boolean` | | Toggle "Edit this page on Github" component on documentation pages | +| `github.branch` | `boolean` | | Toggle "Edit this page on Github" component on documentation pages | +| `github.repo` | `boolean` | | Toggle "Edit this page on Github" component on documentation pages | +| `github.owner` | `boolean` | | Toggle "Edit this page on Github" component on documentation pages | | `github.edit` | `boolean` | | Toggle "Edit this page on Github" component on documentation pages | -| `github.contributors` | `boolean` | | Toggle contributors component on documentation pages | -| `github.root` | `string` | | The root path to use for "Edit on Github" component | diff --git a/.playground/app.config.ts b/.playground/app.config.ts index c395a54b7..7c39a6e5d 100644 --- a/.playground/app.config.ts +++ b/.playground/app.config.ts @@ -1,5 +1,15 @@ export default defineAppConfig({ docus: { - title: 'MDC' + title: 'MDC', + socials: { + github: 'nuxt-themes/docus', + }, + github: { + dir: '.playground/content', + branch: 'dev', + repo: 'docus', + owner: 'nuxt-themes', + edit: true, + } } }) diff --git a/.playground/content/0.index.md b/.playground/content/0.index.md index fad919044..96ffe984b 100644 --- a/.playground/content/0.index.md +++ b/.playground/content/0.index.md @@ -16,5 +16,3 @@ I am using an inline component :counter-button. :: :: - -COucou ca va diff --git a/app.config.ts b/app.config.ts index 51c110058..9b5d826bd 100644 --- a/app.config.ts +++ b/app.config.ts @@ -21,8 +21,19 @@ export default defineAppConfig({ title: '', logo: false, showLinkIcon: false, + fixed: { + initial: true, + lg: true + }, exclude: [] }, + github: { + dir: undefined, + branch: undefined, + repo: undefined, + owner: undefined, + edit: false + }, footer: { credits: { icon: 'IconDocus', diff --git a/components/app/AppLayout.vue b/components/app/AppLayout.vue index 1c8b02aa5..7db5e2432 100644 --- a/components/app/AppLayout.vue +++ b/components/app/AppLayout.vue @@ -3,12 +3,10 @@ const docus = useDocus() const { navigation, page } = useContent() const { navKeyFromPath } = useContentHelpers() -const headerPosition = computed(() => { - return page.value.header?.fixed || docus.value.header.fixed -}) +const headerPosition = computed(() => page.value?.header?.fixed || docus?.value?.header?.fixed || false) const titleTemplate = computed(() => { - const appTitleTemplate = docus.value.head?.titleTemplate || `%s · ${docus.value.title}` + const appTitleTemplate = docus?.value?.titleTemplate || `%s · ${docus?.value?.title}` if (page.value) { return page.value.head?.titleTemplate || navKeyFromPath(page.value._path, 'titleTemplate', navigation.value || []) || appTitleTemplate } @@ -30,9 +28,7 @@ useHead({ ] }) -watch(titleTemplate, () => { - useHead({ titleTemplate: titleTemplate.value }) -}) +watch(titleTemplate, () => useHead({ titleTemplate: titleTemplate.value })) useContentHead(docus.value as any) @@ -40,8 +36,8 @@ useContentHead(docus.value as any) diff --git a/components/docs/DocsPageBottom.vue b/components/docs/DocsPageBottom.vue index bfe9cb82e..693fe918f 100644 --- a/components/docs/DocsPageBottom.vue +++ b/components/docs/DocsPageBottom.vue @@ -6,7 +6,15 @@ const docus = useDocus()