Skip to content

Commit 00a5d63

Browse files
committed
Add TemplateFunctionParams as an object-shaped typedef
1 parent 02c04ba commit 00a5d63

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @import { TemplateFunction } from './lib/build-pages/page-builders/template-builder.js'
88
* @import { TemplateAsyncIterator } from './lib/build-pages/page-builders/template-builder.js'
99
* @import { TemplateOutputOverride } from './lib/build-pages/page-builders/template-builder.js'
10+
* @import { TemplateFunctionParams } from './lib/build-pages/page-builders/template-builder.js'
1011
* @import { GlobalDataFunction, AsyncGlobalDataFunction, WorkerBuildStepResult, GlobalDataFunctionParams } from './lib/build-pages/index.js'
1112
* @import { BuildOptions, BuildContext } from 'esbuild'
1213
* @import { PageInfo, TemplateInfo } from './lib/identify-pages.js'
@@ -130,6 +131,10 @@ export { PageData } from './lib/build-pages/page-data.js'
130131
* @typedef {PageFunctionParams<T, U>} PageFunctionParams
131132
*/
132133

134+
/**
135+
* @template {Record<string, any>} [T=Record<string, any>] - The type of variables for the template function
136+
* @typedef {TemplateFunctionParams<T>} TemplateFunctionParams
137+
*/
133138

134139
const DEFAULT_IGNORES = /** @type {const} */ ([
135140
'.*',

lib/build-pages/page-builders/template-builder.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ import { writeFile, mkdir } from 'fs/promises'
1111
* content: string
1212
* }} TemplateOutputOverride */
1313

14+
/**
15+
* The parameters object passed to a {@link TemplateFunction} or {@link TemplateAsyncIterator}.
16+
*
17+
* @template {Record<string, any>} [T=Record<string, any>] - The type of variables for the template
18+
* @typedef {object} TemplateFunctionParams
19+
* @property {T} vars - All of the site globalVars.
20+
* @property {TemplateInfo} template - Info about the current template.
21+
* @property {PageData<T, any, string>[]} pages - An array of info about every page.
22+
*/
23+
1424
/**
1525
* Callback for rendering a template.
1626
*

0 commit comments

Comments
 (0)