Skip to content

Commit

Permalink
feat: support nuxt.schema for visual edition in studio (#723)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <[email protected]>
  • Loading branch information
atinux and pi0 authored Dec 15, 2022
1 parent 3e054be commit db0829a
Show file tree
Hide file tree
Showing 5 changed files with 597 additions and 527 deletions.
130 changes: 5 additions & 125 deletions app.config.ts
Original file line number Diff line number Diff line change
@@ -1,127 +1,7 @@
export default defineAppConfig({
docus: {
/**
* Website title.
*/
title: 'Docus',
/**
* Website description.
*/
description: 'The best place to start your documentation.',
/**
* Cover image.
*/
image: 'https://user-images.githubusercontent.com/904724/185365452-87b7ca7b-6030-4813-a2db-5e65c785bf88.png',
/**
* Social links.
*
* Will be used in Social Icons component, in AppHeader and AppFooter.
*/
socials: {
// twitter: '@nuxt_js',
// github: 'https://github.com/nuxt-themes/docus',
// facebook: '',
// instagram: '',
// youtube: '',
// medium: ''
},
aside: {
/**
* The level to which the navigation should be scaled.
*
* Use 0 to disable all nesting.
* Use 1 and more to display nested navigation in header and aside navigation.
*/
level: 0,
/**
* Specify if default collapsibles state globally for aside navigation.
*/
collapsed: false,
/**
* Paths to be excluded from aside navigation.
*/
exclude: []
},
header: {
/**
* Title to be displayed in header.
*/
title: '',
/**
* Logo configuration
*
* Boolean to disable or use the `Logo.vue` component.
* String to be used as a name of a component.
*/
logo: false,
/**
* Toggle links icons in the header.
*/
showLinkIcon: false,
/**
* Paths to be excluded from header links.
*/
exclude: []
},
footer: {
/**
* Credits configuration
*
* Object configuring the credits part of footer.
* Boolean to disable.
*/
credits: {
icon: 'IconDocus',
text: 'Powered by Docus',
href: 'https://docus.dev'
},
/**
* Icons to be added to Social Icons in footer.
*/
iconLinks: []
}
}
/**
* Default are defined in nuxt.schema.ts for best typing and Studio integration
* This file can be used to leverage HMR while developping this theme
* Note that this file is not published to npm
*/
})

interface IconLink {
href: string
icon: string
label?: string
}

declare module '@nuxt/schema' {
interface AppConfigInput {
docus?: {
title?: string
description?: string
image?: string
socials?: {
twitter?: string
github?: string
facebook?: string
instagram?: string
youtube?: string
medium?: string
},
aside?: {
level: number
exclude?: string[]
collapsed?: boolean
},
header?: {
title?: string,
logo?: boolean
showLinkIcon?: boolean
exclude?: string[]
},
footer?: {
credits?: boolean | {
icon: string
text: string
href: string
}
iconLinks?: IconLink[]
}
}
}
}
7 changes: 1 addition & 6 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ const envModules = {

export default defineNuxtConfig({
extends: [envModules.typography, envModules.elements],

modules: [
envModules.tokens,
envModules.studio,
'@nuxtjs/color-mode',
'@nuxt/content',
'@vueuse/nuxt',
'nuxt-config-schema',
resolve('./app/module'),
(_, nuxt) => {
if (nuxt.options.dev) {
Expand All @@ -34,11 +34,9 @@ export default defineNuxtConfig({
}
}
],

css: [
resolve('./assets/css/main.css')
],

components: [
{
prefix: '',
Expand All @@ -51,12 +49,10 @@ export default defineNuxtConfig({
global: true
}
],

pinceau: {
configFileName: 'tokens.config',
debug: false
},

content: {
documentDriven: true,
highlight: {
Expand All @@ -70,7 +66,6 @@ export default defineNuxtConfig({
fields: ['icon', 'titleTemplate', 'aside']
}
},

colorMode: {
classSuffix: '',
dataValue: 'theme'
Expand Down
127 changes: 127 additions & 0 deletions nuxt.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
export default defineNuxtConfigSchema({
appConfig: {
docus: {
/**
* Website title, used as header default title and meta title.
*/
title: 'Docus',
/**
* Website description, used for meta description.
*/
description: 'The best place to start your documentation.',
/**
* Cover image.
*
* @example '/cover.jpg'
*/
image:
'https://user-images.githubusercontent.com/904724/185365452-87b7ca7b-6030-4813-a2db-5e65c785bf88.png',
/**
* Social links.
*
* Will be used in Social Icons component, in AppHeader and AppFooter.
*/
socials: {
/**
* Twitter social handle
* @example 'nuxt_js'
*/
twitter: '',
/**
* GitHub org or repository
* @example 'nuxt/framework'
*/
github: '',
facebook: '',
instagram: '',
youtube: '',
medium: ''
},
aside: {
/**
* The level to which the navigation should be scaled.
*
* Use 0 to disable all nesting.
* Use 1 and more to display nested navigation in header and aside navigation.
*/
level: 0,
/**
* Specify if default collapsibles state globally for aside navigation.
*/
collapsed: false,
/**
* Paths to be excluded from aside navigation.
*
* @type {string[]}
*/
exclude: []
},
header: {
/**
* Title to be displayed in header or as aria-label if logo is defined
*
* Default to docus.title
*/
title: '',
/**
* Logo configuration
*
* Boolean to disable or use the `Logo.vue` component.
*
* String to be used as a name of a component.
*
* @example 'MyLogo'
*/
logo: false,
/**
* Toggle links icons in the header.
*/
showLinkIcon: false,
/**
* Paths to be excluded from header links.
*
* @type {string[]}
*/
exclude: []
},
footer: {
/**
* Credits configuration
*
* Object configuring the credits part of footer.
*
* @type {false|object}
*/
credits: {
/**
* Icon to show on credits
* @formtype Icon
*/
icon: 'IconDocus',
text: 'Powered by Docus',
href: 'https://docus.dev'
},
/**
* Icons to be added to Social Icons in footer.
*/
iconLinks: {
$schema: {
type: 'array',
items: {
type: 'object',
required: ['icon', 'href'],
properties: {
icon: { type: 'string', description: 'Icon name' },
href: {
type: 'string',
description: 'Link when clicking on the icon'
},
label: { type: 'string', description: 'Label of the icon' }
}
}
}
}
}
}
}
})
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@nuxtjs/color-mode": "^3.2.0",
"@vueuse/core": "^9.6.0",
"@vueuse/nuxt": "^9.6.0",
"nuxt-config-schema": "^0.3.6",
"pinceau": "latest"
},
"devDependencies": {
Expand Down
Loading

1 comment on commit db0829a

@vercel
Copy link

@vercel vercel bot commented on db0829a Dec 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.