deno.land / x / lume@v2.1.4 / plugins / svgo.ts

نووسراو ببینە
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
33
34
35
36
37
38
39
40
import { optimize } from "../deps/svgo.ts";import { merge } from "../core/utils/object.ts";
import type Site from "../core/site.ts";import type { Page } from "../core/file.ts";import type { Config } from "../deps/svgo.ts";
export interface Options { /** The list of extensions this plugin applies to */ extensions?: string[];
/** Options passed to SVGO. See https://github.com/svg/svgo#configuration */ options?: Config;}
// Default optionsexport const defaults: Options = { extensions: [".svg"],};
/** A plugin to load all SVG files and minify them using SVGO */export default function (userOptions?: Options) { const options = merge(defaults, userOptions);
return (site: Site) => { site.loadAssets(options.extensions); site.process(options.extensions, (pages) => pages.forEach(svg));
function svg(page: Page) { const path = site.src(page.outputPath); const result = optimize(page.content as string, { path, ...options.options, }) as { data: string };
page.content = result.data; } };}
lume

Version Info

Tagged at
7 months ago