VuePress EcosystemVuePress Ecosystem
  • Theme Guidelines
  • theme-default
  • Hope Theme
  • Plume Theme
  • Reco Theme
  • Feature Plugins
  • Markdown Plugins
  • Search Plugins
  • Blog Plugins
  • PWA Plugins
  • Analytics Plugins
  • SEO Plugins
  • Development Plugins
  • Tool Plugins
  • AI Plugins
  • @vuepress/helper
  • English
  • 简体中文
GitHub
  • Theme Guidelines
  • theme-default
  • Hope Theme
  • Plume Theme
  • Reco Theme
  • Feature Plugins
  • Markdown Plugins
  • Search Plugins
  • Blog Plugins
  • PWA Plugins
  • Analytics Plugins
  • SEO Plugins
  • Development Plugins
  • Tool Plugins
  • AI Plugins
  • @vuepress/helper
  • English
  • 简体中文
GitHub
  • back-to-top
  • catalog
  • copy-code
  • copyright
  • icon
  • medium-zoom
  • notice
  • nprogress
  • photo-swipe
  • watermark

watermark

@vuepress/plugin-watermark

Integrate watermark-js-plus into VuePress。

This plugin can add watermark to the pages, you can choose between add watermark globally or on specific pages. You can also choose between add text watermark or image watermark.

Usage

npm i -D @vuepress/plugin-watermark@next
.vuepress/config.ts
import { watermarkPlugin } from '@vuepress/plugin-watermark'

export default {
  plugins: [
    watermarkPlugin({
      // options
    }),
  ],
}

Options

enabled

  • Type: boolean | ((page: Page) => boolean)

  • Default: false

  • Details:

    Specify which pages need to have watermarks added.

    Pages with true value will have watermarks added.

watermarkOptions

  • Type: WatermarkOptions

  • Default: undefined

  • Details: Please refer to the watermark-js-plus configuration options.

watermarkOptions.parent

  • Type: string

  • Default: body

  • Details: Parent element selector for adding watermark.

    By default, it is inserted into the body, but you can specify inserting it into a specific element on the page.

Frontmatter

watermark

  • Type: boolean | WatermarkOptions

  • Details:

    When the type is boolean, it indicates whether the watermark is enabled.

    When the type is WatermarkOptions, it represents the current page's watermark configuration.

    You can refer to watermark-js-plus.

---
watermark:
  width: 200
  height: 200
  content: Your content
  opacity: 0.5
---

Client Config

defineWatermarkConfig(config)

  • Type: (config: MaybeRefOrGetter<WatermarkOptions>) => void

Additional configuration passed to watermark-js-plus.

.vuepress/client.ts
import { defineWatermarkConfig } from '@vuepress/plugin-watermark/client'

defineWatermarkConfig({
  // Set up additional watermark configurations here.
})

In most cases, the majority of options should be defined in Node,
but there are some special situations. For example,
it may be necessary to control different watermark opacities, font colors,
etc., in dark/light mode , or to pass in callbacks such as onSuccess, extraDrawFunc, and so on.

import { useDarkMode } from '@vuepress/helper/client'
import { computed } from 'vue'

export default defineClientConfig({
  setup() {
    const isDark = useDarkMode()

    const watermarkConfig = computed(() => ({
      fontColor: isDark.value ? '#fff' : '#000',
      onSuccess: () => {
        console.log('success')
      },
    }))

    defineWatermarkConfig(watermarkConfig)
  },
})
Edit this page on GitHub
Last Updated:: 4/12/25, 7:03 PM
Contributors: pengzhanbo, Mister-Hope
Prev
photo-swipe