---
title: 更多
author: pengzhanbo
icon: ic:outline-auto-fix-high
createTime: 2024/03/05 16:27:59
permalink: /guide/markdown/advance/
---
## iconify 图标
在 Markdown 文件中使用 [iconify](https://iconify.design/) 的图标。 主题虽然提供了
[`
这是段落
::: ``` **输出:** ::: demo-wrapper这是段落
::: ## can I use 此功能默认不启用,你可以在配置文件中启用它。 ::: code-tabs @tab .vuepress/config.ts ```ts export default defineUserConfig({ theme: plumeTheme({ plugins: { markdownPower: { caniuse: true, // [!code highlight] }, } }) }) ``` ::: 在编写文章时, 提供嵌入 [can-i-use](https://caniuse.com/) WEB feature 各平台支持说明 的功能。 方便在描述某个 WEB feature 时,能更直观的表述 该特性的支持程度。 在你的 文章 markdown文件中,使用以下格式: ``` md @[caniuse](feature) ``` 为了方便使用,主题提供了工具支持:[caniuse 特性搜索](/tools/caniuse/),你可以直接使用该工具 帮助生成 markdown 代码。 ### 语法 ``` md @[caniuse](feature) @[caniuse{browser_versions}](feature) @[caniuse embed_type](feature) @[caniuse embed_type{browser_versions}](feature) ``` - `feature` 必填。 正确取值请参考 [caniuse-embed.vercel.app](https://caniuse-embed.vercel.app/zh-CN) - `{browser_versions}` 可选。当前特性在多个版本中的支持情况。 默认值为: `{-2,1}` 格式: `{past,future}` 取值范围为 `-5 ~ 3` - 小于`0` 表示低于当前浏览器版本的支持情况 - `0` 表示当前浏览器版本的支持情况 - 大于`0` 表示高于当前浏览器版本的支持情况 - `embed_type` 可选。 资源嵌入的类型。 类型: `'embed' | 'image'` 默认值为:`'embed'` :::caution 不再推荐使用 image 类型,建议使用 embed 类型,主题更换了 embed 实现技术方案, 现在的 embed 类型优势已远远超过 image 类型,加载速度更快,体积更小,交互体验更好。 ::: ### 示例 **获取 css 伪类选择器 `:dir()` 在各个浏览器的支持情况:** ```md @[caniuse](css-matches-pseudo) ``` 效果: @[caniuse](css-matches-pseudo) **以图片的形式,获取 css 伪类选择器 `:dir()` 在各个浏览器的支持情况:** ```md @[caniuse image](css-matches-pseudo) ``` 效果: @[caniuse image](css-matches-pseudo) **获取 css 伪类选择器 `:dir()` 特定范围浏览器的支持情况:** ```md @[caniuse{-2,3}](css-matches-pseudo) ``` 效果: @[caniuse{-2,3}](css-matches-pseudo) ## 导入文件 主题支持在 Markdown 文件中导入文件切片。 导入文件 默认不启用,你可以通过配置来启用它。 ::: code-tabs @tab .vuepress/config.ts ```ts export default defineUserConfig({ theme: plumeTheme({ plugins: { markdownEnhance: { include: true, // [!code highlight] }, } }) }) ``` ::: ### 语法 使用 `` 导入文件。 如果要部分导入文件,你可以指定导入的行数: - `` - `` - `` 同时你也可以导入文件区域: - `` ::::tip 文件区域 文件区域是 vscode 中的一个概念,区域内容被 `#region` 和 `#endregion` 注释包围。 :::: ### 高级 你还可以设置一个对象来自定义包含文件路径和包含行为。 ```ts interface IncludeOptions { /** * 处理 include 文件路径 * * @default (path) => path */ resolvePath?: (path: string, cwd: string | null) => string /** * 是否深度导入包含的 Markdown 文件 * * @default false */ deep?: boolean /** * 是否使用 `` 代替 `@include: xxx` 导入文件 * * @default true */ useComment?: boolean /** * 是否解析包含的 Markdown 文件的里的相对图像路径 * * @default true */ resolveImagePath?: boolean /** * 是否解析包含的 Markdown 文件的里的文件相对路径 * * @default true */ resolveLinkPath?: boolean } ``` 例如: 你可以使用 @src 作为源文件夹的别名。 ::: code-tabs @tab .vuepress/config.ts ```ts{5-11} export default defineUserConfig({ theme: plumeTheme({ plugins: { markdownEnhance: { include: { resolvePath: (file) => { if (file.startsWith('@src')) return file.replace('@src', path.resolve(__dirname, '..')) return file }, }, }, } }) }) ``` ::: 此外,如果你想将 Markdown 文件直接放在实际文件旁边,但不希望它们呈现为页面, 你可以在 VuePress 配置中设置 `pagePatterns` 选项。 有关详细信息,请参阅 [pagePatterns](https://vuejs.press/zh/reference/config.html#pagepatterns)。 ::: code-tabs @tab .vuepress/config.ts ```ts export default defineUserConfig({ // 现在任何带有 `.snippet.md` 扩展名的文件都不会呈现为页面 pagePatterns: ['**/*.md', '!**/*.snippet.md', '!.vuepress', '!node_modules'], // [!code ++] theme: plumeTheme({ plugins: { markdownEnhance: { include: true, }, } }) }) ``` ::: ### 示例 在项目中有一个 `foo.snippet.md` 文件: :::: code-tabs @tab foo.snippet.md ```md ### 三级标题 这是 foo.snippet.md 文件中的内容。 ::: info 提示容器包括的内容 ::: 这里是被 `` 包裹的内容。 通过 `` 来引入。 ``` :::: 使用 `` 导入文件: :::: demo-wrapper title="Include by file" :::: 使用 `` 导入文件内的 5 到 7 行: :::: demo-wrapper title="Include by lines" :::: 使用 `` 导入 `snippet` 区域 :::: demo-wrapper title="Include by file region" ::::