blob: e3c5b4b6e29c9706b56f14bb0ca3828d17be14e2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { fileURLToPath } from 'node:url';
import { baseService } from 'astro/assets';
/**
* stub image service that returns images as-is without optimization
* @param {{ foo?: string }} [config]
*/
export function testImageService(config = {}) {
return {
entrypoint: fileURLToPath(import.meta.url),
config,
};
}
/** @type {import("../dist/@types/astro").LocalImageService} */
export default {
...baseService,
propertiesToHash: [...baseService.propertiesToHash, 'data-custom'],
getHTMLAttributes(options, serviceConfig) {
options['data-service'] = 'my-custom-service';
if (serviceConfig.service.config.foo) {
options['data-service-config'] = serviceConfig.service.config.foo;
}
return baseService.getHTMLAttributes(options);
},
async transform(buffer, transform) {
return {
data: buffer,
format: transform.format,
};
},
};
|