mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat(markdown-macro): update include to check for plain file type
This commit is contained in:
@@ -2,7 +2,6 @@ import { escapeRegExp, merge, omit } from 'lodash-es'
|
||||
import frontMatter from 'front-matter'
|
||||
import type { Plugin } from '@fe/context'
|
||||
import type { BuildInSettings, Doc } from '@fe/types'
|
||||
import { MARKDOWN_FILE_EXT } from '@share/misc'
|
||||
import type { MenuItem } from '@fe/services/status-bar'
|
||||
import { render } from '@fe/services/view'
|
||||
import { t } from '@fe/services/i18n'
|
||||
@@ -10,6 +9,7 @@ import { readFile } from '@fe/support/api'
|
||||
import { getLogger, md5 } from '@fe/utils'
|
||||
import { basename, dirname, resolve } from '@fe/utils/path'
|
||||
import { getPurchased } from '@fe/others/premium'
|
||||
import { isPlain } from '@fe/services/document'
|
||||
import ctx from '@fe/context'
|
||||
|
||||
type Result = { __macroResult: true, vars?: Record<string, any>, value: string }
|
||||
@@ -208,8 +208,8 @@ async function include (
|
||||
return { __macroResult: true, value: 'Error: $include maximum call stack size exceeded [3]' }
|
||||
}
|
||||
|
||||
if (!path.endsWith(MARKDOWN_FILE_EXT)) {
|
||||
return { __macroResult: true, value: 'Error: $include markdown file only' }
|
||||
if (!isPlain({ type: 'file', path })) {
|
||||
return { __macroResult: true, value: 'Error: $include path is not a plain file' }
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -166,7 +166,7 @@ export function isEncrypted (doc?: Pick<Doc, 'path' | 'type'> | null): boolean {
|
||||
* @param doc
|
||||
* @returns
|
||||
*/
|
||||
export function isPlain (doc?: PathItemWithType) {
|
||||
export function isPlain (doc?: Omit<PathItemWithType, 'repo'>) {
|
||||
if (!doc) return false
|
||||
|
||||
return doc.type === 'file' &&
|
||||
|
||||
Reference in New Issue
Block a user