mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
feat(theme): add image-preview configuration (#637)
This commit is contained in:
parent
2cbae991af
commit
4590703e63
@ -125,6 +125,7 @@ export const themeGuide: ThemeNote = defineNoteConfig({
|
||||
items: [
|
||||
'icon',
|
||||
'search',
|
||||
'image-preview',
|
||||
'comments',
|
||||
'bulletin',
|
||||
'encryption',
|
||||
|
||||
46
docs/notes/theme/guide/features/image-preview.md
Normal file
46
docs/notes/theme/guide/features/image-preview.md
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
title: 图片预览
|
||||
icon: ri:image-line
|
||||
createTime: 2025/07/03 20:46:17
|
||||
permalink: /guide/features/image-preview/
|
||||
---
|
||||
|
||||
在主题中,图片默认支持点击后放大预览。通过查找 文档内容中的图片,形成图片预览列表。
|
||||
|
||||
该功能由 [@vuepress/plugin-photo-swipe](https://ecosystem.vuejs.press/zh/plugins/features/photo-swipe.html) 插件提供支持。
|
||||
|
||||
## 配置
|
||||
|
||||
图片预览默认启用,也可以通过以下配置修改行为:
|
||||
|
||||
```ts title=".vuepress/config.ts"
|
||||
export default defineUserConfig({
|
||||
theme: plumeTheme({
|
||||
plugins: {
|
||||
photoSwipe: {
|
||||
// 图片选择器
|
||||
selector: '[vp-content] :not(a) > img:not([no-view],.no-view,.ignore)',
|
||||
download: true, // 是否显示下载按钮
|
||||
fullscreen: true, // 是否显示全屏按钮
|
||||
scrollToClose: true, // 是否在滚动时关闭当前图片
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
更多配置请参考 [@vuepress/plugin-photo-swipe](https://ecosystem.vuejs.press/zh/plugins/features/photo-swipe.html)
|
||||
|
||||
## 忽略图片预览
|
||||
|
||||
可以通过 `no-view` 或 `ignore` 类名,或者 `no-view` 属性来忽略图片预览。
|
||||
|
||||
```md
|
||||
{.no-view}
|
||||
{.ignore}
|
||||
{no-view}
|
||||
|
||||
<img src="path/to/image" class="no-view">
|
||||
<img src="path/to/image" class="ignore">
|
||||
<img src="path/to/image" no-view>
|
||||
```
|
||||
@ -53,7 +53,8 @@ export function setupPlugins(
|
||||
// 图片浏览
|
||||
if (pluginOptions.photoSwipe !== false) {
|
||||
plugins.push(photoSwipePlugin({
|
||||
selector: '.plume-content > img, .plume-content :not(a) > img',
|
||||
selector: '[vp-content] :not(a) > img:not([no-view],.no-view,.ignore)',
|
||||
...pluginOptions.photoSwipe,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import type { MarkdownChartPluginOptions } from '@vuepress/plugin-markdown-chart
|
||||
import type { MarkdownImagePluginOptions } from '@vuepress/plugin-markdown-image'
|
||||
import type { MarkdownIncludePluginOptions } from '@vuepress/plugin-markdown-include'
|
||||
import type { MarkdownMathPluginOptions } from '@vuepress/plugin-markdown-math'
|
||||
import type { PhotoSwipePluginOptions } from '@vuepress/plugin-photo-swipe'
|
||||
import type { ReadingTimePluginOptions } from '@vuepress/plugin-reading-time'
|
||||
import type { SeoPluginOptions } from '@vuepress/plugin-seo'
|
||||
import type { ShikiPluginOptions } from '@vuepress/plugin-shiki'
|
||||
@ -49,7 +50,7 @@ export interface ThemeBuiltinPlugins {
|
||||
/**
|
||||
* 图片预览 插件
|
||||
*/
|
||||
photoSwipe?: false
|
||||
photoSwipe?: false | PhotoSwipePluginOptions
|
||||
|
||||
/**
|
||||
* @deprecated 插件相关功能已迁移至其他官方插件,此插件已弃用
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user