30 lines
889 B
TypeScript
Raw Normal View History

2023-03-08 15:59:19 -05:00
interface Page {
url: string | false;
fileSlug: string;
filePathStem: string;
date: Date;
inputPath: string;
outputPath: string | false;
outputFileExtension: string;
}
/**
* Removes leading id (e.g. `001-`) from blog filenames.
*/
export const getBlogSlug = (page: Page) => page.fileSlug.replace(/^(\d*-)/, '');
2023-03-08 15:59:19 -05:00
/**
* Indicates whether the given page is part of the JS API documentation.
*/
export const isTypedoc = (page: Page) =>
page.url ? page.url.startsWith('/documentation/js-api/') : false;
2023-03-09 17:32:49 -05:00
/* eslint-disable @typescript-eslint/no-unsafe-member-access,
@typescript-eslint/no-unsafe-call,
@typescript-eslint/no-explicit-any */
export default function pagesPlugin(eleventyConfig: any) {
// filters...
eleventyConfig.addLiquidFilter('getBlogSlug', getBlogSlug);
2023-03-09 17:32:49 -05:00
eleventyConfig.addLiquidFilter('isTypedoc', isTypedoc);
}