deno.land / x / lume@v2.1.4 / plugins / fff.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type Site from "../core/site.ts";import { getGitDate } from "../core/utils/date.ts";import { merge } from "../core/utils/object.ts";
import { type FFFFlavoredFrontmatter, type FFFTransformPreset, postTypeDiscovery, strict, type StrictPresetOptions, transform,} from "../deps/fff.ts";
export interface Options { /** The list extensions this plugin applies to */ extensions: string[]; presets: FFFTransformPreset[]; strict: false | StrictPresetOptions; date?: "created" | "updated" | "published"; getGitDate?: boolean; postTypeDiscovery?: boolean;}
// Default optionsexport const defaults: Options = { extensions: [".html"], presets: [], strict: false,};
export default function (userOptions?: Partial<Options>) { const options = merge(defaults, userOptions);
return (site: Site) => { site.preprocess(options.extensions, (pages) => pages.forEach((page) => { if (options.getGitDate && page.src.entry) { page.data.created = getGitDate("created", page.src.entry.src); page.data.updated = getGitDate("modified", page.src.entry.src); }
page.data = transform(page.data, [ ...options.presets, ...(options.date ? [{ "date": options.date }] : []), ...(options.strict === false ? [] : [strict(options.strict)]), ]);
if (options.postTypeDiscovery) { page.data.type = postTypeDiscovery(page.data); } })); };}
/** Extends Data interface */declare global { namespace Lume { // deno-lint-ignore no-empty-interface export interface Data extends Omit<FFFFlavoredFrontmatter, "lang" | "tags"> {} }}
lume

Version Info

Tagged at
6 months ago