From 3b1b438243b0638d0d25db69f55999a97a302f08 Mon Sep 17 00:00:00 2001 From: Kevin Van Lierde Date: Sat, 26 Nov 2022 01:39:22 +0100 Subject: [PATCH] Adds Typescript support --- lib/index.d.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/index.d.ts diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..d1e6547 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,29 @@ +import { Plugin } from 'metalsmith'; +import defaultValues from '.'; + +export default defaultValues; +export interface DefaultsSet { + /** 1 or more glob patterns to match files. Defaults to `'**'` (all). */ + pattern?: string; + /** an object whose keys will be set as file metadata keys */ + defaults: { + [key:string]: string; + } +} +export type Options = DefaultsSet|DefaultsSet[] +/** + * Set `defaults` to file metadata matching `pattern`'s. + * + * @example + * metalsmith.use(defaultValues({ + pattern: 'posts/*.md', + defaults: { + layout: 'post.hbs', + draft: false, + date(post) { + return post.stats.ctime + } + } + })) + **/ +declare function defaultValues(options: Options): Plugin; \ No newline at end of file