Skip to content

Commit 3125905

Browse files
authored
chore(typescript): compatibility with nuxt 4 (keeping old tsconfig for the moment) (#1115)
1 parent 185d2b8 commit 3125905

File tree

6 files changed

+64
-58
lines changed

6 files changed

+64
-58
lines changed

app/app/types/index.d.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
declare module 'nuxt/schema' {
2+
interface AppConfig {
3+
seo: {
4+
titleTemplate: string
5+
title: string
6+
description: string
7+
}
8+
header: {
9+
title: string
10+
logo: {
11+
light: string
12+
dark: string
13+
alt: string
14+
}
15+
}
16+
socials: Record<string, string>
17+
toc: {
18+
title: string
19+
bottom: {
20+
title: string
21+
links: {
22+
icon: string
23+
label: string
24+
to: string
25+
target: string
26+
}[]
27+
}
28+
}
29+
github: {
30+
owner: string
31+
name: string
32+
url: string
33+
branch: string
34+
rootDir?: string
35+
}
36+
}
37+
}
38+
39+
export {}

app/app/utils/git.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ export function getGitBranch() {
2929
}
3030
}
3131
catch {
32-
return 'main'
32+
// Ignore error
3333
}
34+
35+
return 'main'
3436
}
3537

3638
export async function getLocalGitInfo(rootDir: string): Promise<GitInfo | undefined> {
@@ -63,7 +65,7 @@ async function getLocalGitRemote(dir: string): Promise<string | undefined> {
6365
}
6466
}
6567

66-
export function getGitEnv(): GitInfo | undefined {
68+
export function getGitEnv(): GitInfo {
6769
// https://github.com/unjs/std-env/issues/59
6870
const envInfo = {
6971
// Provider

app/modules/default-configs.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,25 @@ export default defineNuxtModule({
3030
debug: false,
3131
})
3232

33-
nuxt.options.appConfig = defu(nuxt.options.appConfig, {
34-
header: {
35-
title: siteName,
36-
},
37-
github: {
38-
owner: gitInfo?.owner,
39-
name: gitInfo?.name,
40-
url: gitInfo?.url,
41-
branch: getGitBranch(),
42-
},
43-
seo: {
44-
titleTemplate: `%s - ${siteName}`,
45-
title: siteName,
46-
description: meta.description || '',
47-
},
48-
toc: {},
33+
nuxt.options.appConfig.header = defu(nuxt.options.appConfig.header, {
34+
title: siteName,
35+
})
36+
37+
nuxt.options.appConfig.seo = defu(nuxt.options.appConfig.seo, {
38+
titleTemplate: `%s - ${siteName}`,
39+
title: siteName,
40+
description: meta.description || '',
41+
})
42+
43+
nuxt.options.appConfig.github = defu(nuxt.options.appConfig.github, {
44+
owner: gitInfo?.owner,
45+
name: gitInfo?.name,
46+
url: gitInfo?.url,
47+
branch: getGitBranch(),
48+
})
49+
50+
nuxt.options.appConfig.toc = defu(nuxt.options.appConfig.toc, {
51+
title: 'On this page',
4952
})
5053
},
5154
})

app/nuxt.schema.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -216,41 +216,3 @@ export default defineNuxtSchema({
216216
}),
217217
},
218218
})
219-
220-
declare module '@nuxt/schema' {
221-
interface AppConfig {
222-
seo: {
223-
titleTemplate: string
224-
title: string
225-
description: string
226-
}
227-
header: {
228-
title: string
229-
logo: {
230-
light: string
231-
dark: string
232-
alt: string
233-
}
234-
}
235-
socials: Record<string, string>
236-
toc: {
237-
title: string
238-
bottom: {
239-
title: string
240-
links: {
241-
icon: string
242-
label: string
243-
to: string
244-
target: string
245-
}[]
246-
}
247-
}
248-
github: {
249-
owner: string
250-
name: string
251-
url: string
252-
branch: string
253-
rootDir?: string
254-
}
255-
}
256-
}

app/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"extends": "./.nuxt/tsconfig.json"
3-
}
3+
}

docs/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"extends": "./.nuxt/tsconfig.json"
3-
}
3+
}

0 commit comments

Comments
 (0)