2023-03-08 21:59:19 +01:00
|
|
|
interface Page {
|
|
|
|
url: string | false;
|
|
|
|
fileSlug: string;
|
|
|
|
filePathStem: string;
|
|
|
|
date: Date;
|
|
|
|
inputPath: string;
|
|
|
|
outputPath: string | false;
|
|
|
|
outputFileExtension: string;
|
|
|
|
}
|
|
|
|
|
2023-03-10 22:44:54 +01:00
|
|
|
/**
|
|
|
|
* Removes leading id (e.g. `001-`) from blog filenames.
|
|
|
|
*/
|
|
|
|
export const getBlogSlug = (page: Page) => page.fileSlug.replace(/^(\d*-)/, '');
|
|
|
|
|
2023-03-08 21:59:19 +01: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 23:32:49 +01:00
|
|
|
|
2023-06-20 18:13:03 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2023-03-09 23:32:49 +01:00
|
|
|
export default function pagesPlugin(eleventyConfig: any) {
|
|
|
|
// filters...
|
2023-03-10 22:44:54 +01:00
|
|
|
eleventyConfig.addLiquidFilter('getBlogSlug', getBlogSlug);
|
2023-03-09 23:32:49 +01:00
|
|
|
eleventyConfig.addLiquidFilter('isTypedoc', isTypedoc);
|
|
|
|
}
|