Skip to content

Commit f8ac1a8

Browse files
committed
feat(images): image formats and quality configurable
1 parent c751788 commit f8ac1a8

File tree

3 files changed

+57
-8
lines changed

3 files changed

+57
-8
lines changed

.playground/app.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
import type { ImageConfiguration } from '../types'
2+
13
export default defineAppConfig({
24
attributeContent: {
35
name: 'Nuxt Attribute Content (overwritten)',
6+
images: (): ImageConfiguration => {
7+
const images = {
8+
formats: [
9+
{
10+
format: 'avif',
11+
quality: 70,
12+
},
13+
{
14+
format: 'webp',
15+
quality: 85,
16+
},
17+
],
18+
}
19+
return images
20+
},
421
},
522
})

app.config.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
export default defineAppConfig({
22
attributeContent: {
33
name: 'Nuxt Attribute Content',
4+
images: {
5+
formats: [
6+
{
7+
format: 'avif',
8+
quality: 60,
9+
},
10+
{
11+
format: 'webp',
12+
quality: 75,
13+
},
14+
],
15+
},
416
},
517
})
6-
7-
declare module '@nuxt/schema' {
8-
interface AppConfigInput {
9-
attributeContent?: {
10-
name?: string
11-
}
12-
}
13-
}

types/index.d.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export interface ImageFormat {
2+
format: string
3+
quality: number
4+
}
5+
6+
export interface ImageConfiguration {
7+
formats: ImageFormat[]
8+
}
9+
10+
export type ImageConfigValue = ImageConfiguration | (() => ImageConfiguration)
11+
12+
declare module '@nuxt/schema' {
13+
interface AppConfigInput {
14+
attributeContent?: {
15+
name?: string
16+
images?: ImageConfigValue
17+
}
18+
}
19+
interface AppConfig {
20+
attributeContent: {
21+
name: string
22+
images: ImageConfiguration
23+
}
24+
}
25+
}
26+
27+
// It is always important to ensure you import/export something when augmenting a type
28+
export {}

0 commit comments

Comments
 (0)