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
  • @vuepress/helper
    • Node

      • Bundler Related
      • Locales Related
      • Page Related
    • Client Related
    • Shared Methods
    • Styles

Page Related

Common information generator for pages.

getPageExcerpt

Get the excerpt of the page.

export interface PageExcerptOptions {
  /**
   * Excerpt separator
   *
   * @default "<!-- more -->"
   */
  separator?: string

  /**
   * Length of excerpt
   *
   * @description Excerpt length will be the minimal possible length reaching this value
   *
   * @default 300
   */
  length?: number

  /**
   * Tags which is considered as custom elements
   *
   * @description This is used to determine whether a tag is a custom element since all unknown tags are removed in excerpt.
   */
  isCustomElement?: (tagName: string) => boolean

  /**
   * Whether keep page title (first h1) in excerpt
   *
   * @default false
   */
  keepPageTitle?: boolean

  /**
   * Whether preserve tags like line numbers and highlight lines for code blocks
   *
   * @default false
   */
  keepFenceDom?: boolean
}

export const getPageExcerpt: (
  app: App,
  page: Page,
  options?: PageExcerptOptions,
) => string

getPageText

Get plain text of the page.

export interface PageTextOptions {
  /**
   * Whether convert text to single line content
   *
   * @default false
   */
  singleLine?: boolean

  /**
   * Length of text
   *
   * @description Text length will be the minimal possible length reaching this value
   *
   * @default 300
   */
  length?: number

  /**
   * Tags to be removed
   *
   * @description Table and code blocks are removed by default.
   *
   * @default ['table', 'pre']
   */
  removedTags?: string[]
}

export const getPageText: (
  app: App,
  page: Page,
  options?: PageTextOptions,
) => string
Edit this page on GitHub
Last Updated:: 1/10/25, 6:07 PM
Contributors: Mister-Hope
Prev
Locales Related