Fix astro check errors
This commit is contained in:
@@ -16,14 +16,12 @@ const { tags, class: className = 'text-sm', title = undefined, isCategory = fals
|
|||||||
|
|
||||||
{
|
{
|
||||||
tags && Array.isArray(tags) && (
|
tags && Array.isArray(tags) && (
|
||||||
<>
|
|
||||||
<>
|
<>
|
||||||
{title !== undefined && (
|
{title !== undefined && (
|
||||||
<span class="align-super font-normal underline underline-offset-4 decoration-2 dark:text-slate-400">
|
<span class="align-super font-normal underline underline-offset-4 decoration-2 dark:text-slate-400">
|
||||||
{title}
|
{title}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</>
|
|
||||||
<ul class={className}>
|
<ul class={className}>
|
||||||
{tags.map((tag) => (
|
{tags.map((tag) => (
|
||||||
<li class="bg-gray-100 dark:bg-slate-700 inline-block mr-2 rtl:mr-0 rtl:ml-2 mb-2 py-0.5 px-2 lowercase font-medium">
|
<li class="bg-gray-100 dark:bg-slate-700 inline-block mr-2 rtl:mr-0 rtl:ml-2 mb-2 py-0.5 px-2 lowercase font-medium">
|
||||||
|
@@ -1,14 +1,16 @@
|
|||||||
import getReadingTime from 'reading-time';
|
import getReadingTime from 'reading-time';
|
||||||
import { toString } from 'mdast-util-to-string';
|
import { toString } from 'mdast-util-to-string';
|
||||||
import { visit } from 'unist-util-visit';
|
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 = () => {
|
export const readingTimeRemarkPlugin: RemarkPlugin = () => {
|
||||||
return function (tree, file) {
|
return function (tree, file) {
|
||||||
const textOnPage = toString(tree);
|
const textOnPage = toString(tree);
|
||||||
const readingTime = Math.ceil(getReadingTime(textOnPage).minutes);
|
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