Commit 84f56fe
Changed files (3)
src/plugins/rehype-wrap-tables.mjs
@@ -1,5 +1,12 @@
import { visit } from 'unist-util-visit';
+/**
+ * Rehype plugin to wrap tables with a div for overflow auto
+ *
+ * Rehype 插件,为表格包裹一个带有 overflow auto 样式的 div
+ *
+ * @returns {import('unified').Plugin}
+ */
export function rehypeWrapTables() {
return (tree) => {
visit(tree, 'element', (node, index, parent) => {
src/plugins/remark-excerpt.js
@@ -1,6 +1,12 @@
import { toString } from 'mdast-util-to-string';
-/* Use the post's first paragraph as the excerpt */
+/**
+ * Remark plugin to extract the first paragraph as excerpt
+ *
+ * 提取第一个段落作为摘要的 Remark 插件
+ *
+ * @returns {import('unified').Plugin}
+ */
export function remarkExcerpt() {
return (tree, { data }) => {
let excerpt = '';
src/plugins/remark-reading-time.mjs
@@ -1,6 +1,13 @@
import { toString } from 'mdast-util-to-string';
import getReadingTime from 'reading-time';
+/**
+ * Remark plugin to calculate reading time and word count
+ *
+ * Remark 插件,用于计算阅读时间和字数
+ *
+ * @returns {import('unified').Plugin}
+ */
export function remarkReadingTime() {
return (tree, { data }) => {
const textOnPage = toString(tree);