diff --git a/plugins/plugin-shikiji/src/node/markdown/lineNumberPlugin.ts b/plugins/plugin-shikiji/src/node/markdown/lineNumberPlugin.ts index 718d389f..fe911347 100644 --- a/plugins/plugin-shikiji/src/node/markdown/lineNumberPlugin.ts +++ b/plugins/plugin-shikiji/src/node/markdown/lineNumberPlugin.ts @@ -6,6 +6,7 @@ import type { LineNumberOptions } from '../types.js' const LINE_NUMBERS_REGEXP = /:line-numbers\b/ const NO_LINE_NUMBERS_REGEXP = /:no-line-numbers\b/ +const LINE_NUMBERS_START_REGEXP = /:line-numbers=(\d+)\b/ export function lineNumberPlugin(md: Markdown, { lineNumbers = true }: LineNumberOptions = {}): void { const rawFence = md.renderer.rules.fence! @@ -41,11 +42,15 @@ export function lineNumberPlugin(md: Markdown, { lineNumbers = true }: LineNumbe ) return rawCode + const startNumbers + = Number(info.match(LINE_NUMBERS_START_REGEXP)?.[1] ?? 1) - 1 + const lineNumbersStyle = `style="counter-reset:line-number ${startNumbers}"` + const lineNumbersCode = [...Array(lines.length)] .map(() => `
`) .join('') - const lineNumbersWrapperCode = `` + const lineNumbersWrapperCode = `` const finalCode = rawCode .replace(/<\/div>$/, `${lineNumbersWrapperCode}`) diff --git a/theme/src/client/components/Page.vue b/theme/src/client/components/Page.vue index 66fa9944..b0a49ef3 100644 --- a/theme/src/client/components/Page.vue +++ b/theme/src/client/components/Page.vue @@ -1,7 +1,5 @@ diff --git a/theme/src/client/styles/vars.scss b/theme/src/client/styles/vars.scss index 5dfadab6..55215439 100644 --- a/theme/src/client/styles/vars.scss +++ b/theme/src/client/styles/vars.scss @@ -672,3 +672,11 @@ html.dark { --vp-c-plot-dark: var(--vp-c-bg); --vp-c-bg-plot-dark: var(--vp-c-text-2); } + +/** + * plugin-photo-swipe + * -------------------------------------------------------------------------- */ +:root { + --photo-swipe-bullet: var(--vp-c-bg); + --photo-swipe-bullet-active: var(--vp-c-brand-1); +} diff --git a/theme/src/node/plugins/getPlugins.ts b/theme/src/node/plugins/getPlugins.ts index 6da1dfa8..a808498b 100644 --- a/theme/src/node/plugins/getPlugins.ts +++ b/theme/src/node/plugins/getPlugins.ts @@ -2,7 +2,7 @@ import type { App, PluginConfig } from 'vuepress/core' import { activeHeaderLinksPlugin } from '@vuepress/plugin-active-header-links' import { docsearchPlugin } from '@vuepress/plugin-docsearch' import { gitPlugin } from '@vuepress/plugin-git' -import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom' +import { photoSwipePlugin } from '@vuepress/plugin-photo-swipe' import { nprogressPlugin } from '@vuepress/plugin-nprogress' import { themeDataPlugin } from '@vuepress/plugin-theme-data' import { autoFrontmatterPlugin } from '@vuepress-plume/plugin-auto-frontmatter' @@ -100,10 +100,9 @@ export function getPlugins({ })) } - if (pluginOptions.mediumZoom !== false) { - plugins.push(mediumZoomPlugin({ + if (pluginOptions.photoSwipe !== false) { + plugins.push(photoSwipePlugin({ selector: '.plume-content > img, .plume-content :not(a) > img', - zoomOptions: { background: 'var(--vp-c-bg)' }, delay: 300, })) } diff --git a/theme/src/shared/options/plugins.ts b/theme/src/shared/options/plugins.ts index d52e5ab9..b5b414f6 100644 --- a/theme/src/shared/options/plugins.ts +++ b/theme/src/shared/options/plugins.ts @@ -45,7 +45,7 @@ export interface PlumeThemePluginOptions { nprogress?: false - mediumZoom?: false + photoSwipe?: false markdownEnhance?: false | MarkdownEnhancePluginOptions