first commit
This commit is contained in:
54
app/modules/default-configs.ts
Normal file
54
app/modules/default-configs.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { defineNuxtModule } from '@nuxt/kit'
|
||||
import { defu } from 'defu'
|
||||
import { inferSiteURL, getPackageJsonMetadata } from '../app/utils/meta'
|
||||
import { getGitBranch, getGitEnv, getLocalGitInfo } from '../app/utils/git'
|
||||
|
||||
export default defineNuxtModule({
|
||||
meta: {
|
||||
name: 'default-configs',
|
||||
},
|
||||
async setup(_options, nuxt) {
|
||||
const dir = nuxt.options.rootDir
|
||||
const url = inferSiteURL()
|
||||
const meta = await getPackageJsonMetadata(dir)
|
||||
const gitInfo = await getLocalGitInfo(dir) || getGitEnv()
|
||||
const siteName = nuxt.options?.site?.name || meta.name || gitInfo?.name || ''
|
||||
|
||||
nuxt.options.llms = defu(nuxt.options.llms, {
|
||||
domain: url,
|
||||
title: siteName,
|
||||
description: meta.description || '',
|
||||
full: {
|
||||
title: siteName,
|
||||
description: meta.description || '',
|
||||
},
|
||||
})
|
||||
|
||||
nuxt.options.site = defu(nuxt.options.site, {
|
||||
url,
|
||||
name: siteName,
|
||||
debug: false,
|
||||
})
|
||||
|
||||
nuxt.options.appConfig.header = defu(nuxt.options.appConfig.header, {
|
||||
title: siteName,
|
||||
})
|
||||
|
||||
nuxt.options.appConfig.seo = defu(nuxt.options.appConfig.seo, {
|
||||
titleTemplate: `%s - ${siteName}`,
|
||||
title: siteName,
|
||||
description: meta.description || '',
|
||||
})
|
||||
|
||||
nuxt.options.appConfig.github = defu(nuxt.options.appConfig.github, {
|
||||
owner: gitInfo?.owner,
|
||||
name: gitInfo?.name,
|
||||
url: gitInfo?.url,
|
||||
branch: getGitBranch(),
|
||||
})
|
||||
|
||||
nuxt.options.appConfig.toc = defu(nuxt.options.appConfig.toc, {
|
||||
title: 'On this page',
|
||||
})
|
||||
},
|
||||
})
|
Reference in New Issue
Block a user