Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(markdown-it-unlazy-img): add configuration of vue when using unlazy-img #365

Merged
merged 6 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/pages/en/integrations/markdown-it-unlazy-img/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ yarn add @nolebase/markdown-it-unlazy-img -D

### Integrate with VitePress

In the VitePress configuration file (usually `docs/.vitepress/config.ts`, the file path and extension may be different), import `@nolebase/markdown-it-unlazy-img` as a plugin, and use it as a `markdown-it` plugin in the `markdown` option:
In the VitePress configuration file (usually `docs/.vitepress/config.ts`, the file path and extension may be different), import `@nolebase/markdown-it-unlazy-img` as a plugin, and use it as a `markdown-it` plugin in the `markdown` option, specify how to handle the image resource paths of the `NolebaseUnlazyImg` tag in Vue templates to ensure that VitePress can correctly resolve and transform the image resource paths during the build process:

<!--@include: @/pages/en/snippets/details-colored-diff.md-->

Expand All @@ -48,6 +48,14 @@ import { defineConfigWithTheme } from 'vitepress'
import { UnlazyImages } from '@nolebase/markdown-it-unlazy-img' // [!code ++]

export default defineConfigWithTheme({
vue: {
template: {
transformAssetUrls: {
// Other configurations...
nekomeowww marked this conversation as resolved.
Show resolved Hide resolved
NolebaseUnlazyImg: ['src'], // [!code ++]
},
},
},
lang: 'en',
title: 'Site name', // For reference only, please do not copy directly
description: 'Description', // For reference only, please do not copy directly
Expand All @@ -56,7 +64,7 @@ export default defineConfigWithTheme({
},
markdown: {
config: (md) => {
md.use(md.use(UnlazyImages(), { // [!code ++]
md.use(UnlazyImages(), { // [!code ++]
imgElementTag: 'NolebaseUnlazyImg', // [!code ++]
}) // [!code ++]
},
Expand Down
12 changes: 10 additions & 2 deletions docs/pages/zh-CN/integrations/markdown-it-unlazy-img/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ yarn add @nolebase/markdown-it-unlazy-img -D

### 为 VitePress 配置

在 VitePress 的配置文件中(通常为 `docs/.vitepress/config.ts`,文件路径和拓展名也许会有区别),将 `@nolebase/markdown-it-unlazy-img` 作为一个插件导入,并将其作为 `markdown` 选项的 `markdown-it` 插件使用:
在 VitePress 的配置文件中(通常为 `docs/.vitepress/config.ts`,文件路径和拓展名也许会有区别),将 `@nolebase/markdown-it-unlazy-img` 作为一个插件导入,并将其作为 `markdown` 选项的 `markdown-it` 插件使用,指定如何处理 Vue 模板中 `NolebaseUnlazyImg` 标签的图片资源路径,确保在构建过程中 VitePress 能够正确地解析和转换图片资源路径

<!--@include: @/pages/zh-CN/snippets/details-colored-diff.md-->

Expand All @@ -48,6 +48,14 @@ import { defineConfigWithTheme } from 'vitepress'
import { UnlazyImages } from '@nolebase/markdown-it-unlazy-img' // [!code ++]

export default defineConfigWithTheme({
vue: {
template: {
transformAssetUrls: {
// 其他各种配置...
NolebaseUnlazyImg: ['src'], // [!code ++]
},
},
},
lang: 'zh-CN',
title: '网站名称', // 仅供参考,请不要直接复制
description: '某些介绍', // 仅供参考,请不要直接复制
Expand All @@ -56,7 +64,7 @@ export default defineConfigWithTheme({
},
markdown: {
config: (md) => {
md.use(md.use(UnlazyImages(), { // [!code ++]
md.use(UnlazyImages(), { // [!code ++]
imgElementTag: 'NolebaseUnlazyImg', // [!code ++]
}) // [!code ++]
},
Expand Down
Loading