diff --git a/plugins/plugin-md-power/src/node/demo/watcher.ts b/plugins/plugin-md-power/src/node/demo/watcher.ts
index fb66e943..dad01f3f 100644
--- a/plugins/plugin-md-power/src/node/demo/watcher.ts
+++ b/plugins/plugin-md-power/src/node/demo/watcher.ts
@@ -2,6 +2,7 @@ import type { FSWatcher } from 'chokidar'
import type { App } from 'vuepress'
import fs from 'node:fs'
import path from 'node:path'
+import { deleteKey } from '@pengzhanbo/utils'
import { watch } from 'chokidar'
import { compileCode, parseEmbedCode } from './normal.js'
import { readFileSync } from './supports/file.js'
@@ -77,7 +78,7 @@ export function demoWatcher(app: App, watchers: any[]): void {
})
watcher.on('unlink', (path) => {
- delete tasks[path]
+ deleteKey(tasks, path)
watcher!.unwatch(path)
})
diff --git a/plugins/plugin-md-power/src/node/embed/createEmbedRuleBlock.ts b/plugins/plugin-md-power/src/node/embed/createEmbedRuleBlock.ts
index b9b5b61f..829c5fa2 100644
--- a/plugins/plugin-md-power/src/node/embed/createEmbedRuleBlock.ts
+++ b/plugins/plugin-md-power/src/node/embed/createEmbedRuleBlock.ts
@@ -66,11 +66,12 @@ export interface EmbedRuleBlockOptions> {
*
* 创建嵌入规则块
*
- * Syntax: @[name]()
- * 语法:@[name]()
+ * Syntax: \@\[name]()
+ *
+ * 语法:\@\[name]()
*
* @param md - Markdown instance / Markdown 实例
- * @param options - Embed rule block options / 嵌入规则块选项
+ * @param {EmbedRuleBlockOptions} options - Embed rule block options / 嵌入规则块选项
* @typeParam Meta - Metadata type / 元数据类型
*/
export function createEmbedRuleBlock = Record>(
diff --git a/plugins/plugin-md-power/src/node/enhance/docsTitle.ts b/plugins/plugin-md-power/src/node/enhance/docsTitle.ts
index da783008..c77111a2 100644
--- a/plugins/plugin-md-power/src/node/enhance/docsTitle.ts
+++ b/plugins/plugin-md-power/src/node/enhance/docsTitle.ts
@@ -21,7 +21,7 @@ const REG_HEADING = /^#\s*?([^#\s].*)?\n/
* @param md - Markdown instance / Markdown 实例
*/
export function docsTitlePlugin(md: Markdown): void {
- const render = md.render
+ const render = md.render.bind(md)
md.render = (source, env: MarkdownEnv) => {
if (!env.filePathRelative)
return render(source, env)
diff --git a/theme/src/node/collections/compat.ts b/theme/src/node/collections/compat.ts
index 7c16a65a..61564c0a 100644
--- a/theme/src/node/collections/compat.ts
+++ b/theme/src/node/collections/compat.ts
@@ -1,5 +1,5 @@
import type { ThemeDocCollection, ThemeOptions } from '../../shared/index.js'
-import { toArray } from '@pengzhanbo/utils'
+import { deleteKey, toArray } from '@pengzhanbo/utils'
import { removeLeadingSlash } from 'vuepress/shared'
import { path } from 'vuepress/utils'
@@ -64,10 +64,8 @@ export function compatBlogAndNotesToCollections(options: ThemeOptions): void {
}) as ThemeDocCollection))
}
}
-
- delete opt.notes
+ deleteKey(opt, 'notes')
}
- delete options.blog
- delete options.notes
+ deleteKey(options, ['blog', 'notes'])
}
diff --git a/theme/src/node/pages/encryptPage.ts b/theme/src/node/pages/encryptPage.ts
index 77fc3877..3732673f 100644
--- a/theme/src/node/pages/encryptPage.ts
+++ b/theme/src/node/pages/encryptPage.ts
@@ -1,6 +1,6 @@
import type { Page } from 'vuepress/core'
import type { ThemePageData } from '../../shared/index.js'
-import { toArray } from '@pengzhanbo/utils'
+import { deleteKey, toArray } from '@pengzhanbo/utils'
import pMap from 'p-map'
import { genEncrypt } from '../utils/index.js'
@@ -16,5 +16,5 @@ export async function encryptPage(
if (password.length) {
page.data._e = (await pMap(password, item => genEncrypt(item))).join(':')
}
- delete page.frontmatter.password
+ deleteKey(page.frontmatter, 'password')
}
diff --git a/theme/src/node/pages/extendsPage.ts b/theme/src/node/pages/extendsPage.ts
index 249696c5..c2a0a57d 100644
--- a/theme/src/node/pages/extendsPage.ts
+++ b/theme/src/node/pages/extendsPage.ts
@@ -1,5 +1,6 @@
import type { Page } from 'vuepress/core'
import type { ThemePageData } from '../../shared/index.js'
+import { deleteKey } from '@pengzhanbo/utils'
import { findCollection } from '../collections/findCollection.js'
import { autoCategory } from './autoCategory.js'
import { encryptPage } from './encryptPage.js'
@@ -33,7 +34,7 @@ function cleanPageData(page: Page) {
if (page.frontmatter.home) {
page.frontmatter.pageLayout = 'home'
- delete page.frontmatter.home
+ deleteKey(page.frontmatter, 'home')
}
if (page.headers) {
@@ -45,14 +46,14 @@ function cleanPageData(page: Page) {
page.data.type = 'friends'
page.permalink = page.permalink ?? '/friends/'
page.frontmatter.pageLayout = 'friends'
- delete page.frontmatter.friends
+ deleteKey(page.frontmatter, 'friends')
}
const pageType = page.frontmatter._pageLayout as string
if (pageType) {
page.frontmatter.draft = true
page.data.type = pageType as any
- delete page.frontmatter._pageLayout
+ deleteKey(page.frontmatter, '_pageLayout')
}
if (page.frontmatter.pageLayout === 'blog' || page.frontmatter.pageLayout === 'posts') {
@@ -62,7 +63,7 @@ function cleanPageData(page: Page) {
if ('externalLink' in page.frontmatter) {
page.frontmatter.externalLinkIcon = page.frontmatter.externalLink
- delete page.frontmatter.externalLink
+ deleteKey(page.frontmatter, 'externalLink')
}
// is markdown file
diff --git a/theme/src/node/prepare/prepareSidebar.ts b/theme/src/node/prepare/prepareSidebar.ts
index 4cd43698..fb844998 100644
--- a/theme/src/node/prepare/prepareSidebar.ts
+++ b/theme/src/node/prepare/prepareSidebar.ts
@@ -7,6 +7,7 @@ import type {
ThemeSidebar,
ThemeSidebarItem,
} from '../../shared/index.js'
+import { deleteKey } from '@pengzhanbo/utils'
import {
ensureLeadingSlash,
entries,
@@ -191,15 +192,14 @@ function cleanSidebar(sidebar: (ThemeSidebarItem)[]) {
if (isPlainObject(item)) {
if (isArray(item.items)) {
if (item.items.length === 0) {
- delete item.items
- delete item.collapsed
+ deleteKey(item, ['items', 'collapsed'])
}
else {
cleanSidebar(item.items as ThemeSidebarItem[])
}
}
else if (!('items' in item)) {
- delete item.collapsed
+ deleteKey(item, 'collapsed')
}
}
}