Fix astro check errors
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import getReadingTime from 'reading-time';
|
||||
import { toString } from 'mdast-util-to-string';
|
||||
import { visit } from 'unist-util-visit';
|
||||
import type { MarkdownAstroData, RehypePlugin, RemarkPlugin } from '@astrojs/markdown-remark';
|
||||
import type { RehypePlugin, RemarkPlugin } from '@astrojs/markdown-remark';
|
||||
|
||||
export const readingTimeRemarkPlugin: RemarkPlugin = () => {
|
||||
return function (tree, file) {
|
||||
const textOnPage = toString(tree);
|
||||
const readingTime = Math.ceil(getReadingTime(textOnPage).minutes);
|
||||
|
||||
(file.data.astro as MarkdownAstroData).frontmatter.readingTime = readingTime;
|
||||
if (typeof file?.data?.astro?.frontmatter !== "undefined") {
|
||||
file.data.astro.frontmatter.readingTime = readingTime;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user