Skip to content
CONSTRUCTING

Enhanced Readabilities v2.0.0-rc14

Word count
3612 words
Reading time
23 minutes

Demo

See the button in the upper right corner on navigation bar? You can use your mouse to hover over it to see the supported features, click on the one you are interested in to see the effect!

Caution

The "Layout Switch" and "Spotlight" features of Enhanced Readabilities plugin are temporarily unavailable on screens on mobile devices, so if you're reading on mobile but still want to see the results, check out the video demo below.

Video demo

Why

I often find myself uncomfortable reading code blocks and other wide elements in VitePress-built sites, and this discomfort is often due to the presence of code blocks and elements in the body of the text that need to be scrolled through, even though shorter content is easier to read and scan, the scrolling can worse the reading experience entirely, so this plugin tries to solve this (and many more) problems from another angle.

Problems solved

  1. Expand the width of the content on a large screen, in order to better utilize the space to facilitate the reading of some of the oversized and wide code blocks and elements.
  2. Users and readers may have dyslexia, widening the layout may not be conducive to read multiple lines of text, there may be a serial reading situation, so we need an in-line reading aid .
  3. When reading languages that use spaces to separate words, such as English, we need a word-level reading aid, such as bionic reading. (In progress)

These are just some of the issues I can think of that I've been able to address in my long hours of learning and using the plugin, and the plugin doesn't limit itself to working on these issues. You can also open a separate Issue in GitHub to discuss problems you think might be solved and your ideas.

I know that this kind of functionality can be made into a browser plugin to cover a wide variety of different sites, but I think VitePress is clearly a better and faster testing playground, and since Nólëbase is based on VitePress, I wanted to make this plugin as part of an integration that would make it easy for me and everyone else to integrate it directly into the VitePress project and give it a try.

Features included

  1. Layout switch
  2. Spotlight

How to use

Installation

I can't wait, just tell me how to get it into my project!

You can install @nolebase/vitepress-plugin-enhanced-readabilities as one of your VitePress project dependencies with the following command:

shell
pnpm add @nolebase/vitepress-plugin-enhanced-readabilities -D
shell
npm install @nolebase/vitepress-plugin-enhanced-readabilities -D
shell
yarn add @nolebase/vitepress-plugin-enhanced-readabilities -D

Integrate with VitePress

It consists two major steps to integrate the Enhanced Readabilities plugin into your VitePress project:

  1. Add plugin-specific options into configurations of Vite
  2. Add plugin into the Theme options of VitePress

Add plugin-specific options into configurations of Vite

First of all, in VitePress's primary configuration file (not this is not a theme configuration file, it's usually located at docs/.vitepress/config.ts, file paths and extensions may be vary), you need to supply some of the Server-Side Rendering related options in the root configuration object of Vite.

Add the Enhanced Readabilities plugin package name @nolebase/vitepress-plugin-enhanced-readabilities into the Vite options that required by VitePress to process this plugin:

If you've never seen a colored diff before

This is a markup rule for displaying diff in the user interface (UI).

Red parts usually represents the lines you are going to remove, commonly appeared with a Minus sign -, or you could simply understand it as: this line will be removed.

Green parts usually represents the lines you are going to add, commonly appeared with a Plus sign +, or you could simply understand it as: this line will be added.

To learn more about diff, you can check out this answer about the history of diffutils and Git's documentation

是 TypeScript 用户吗?

至少需要配置下面的几个选项:

jsonc
{
  "compilerOptions": {
    "module": "ESNext", 
    "moduleResolution": "Bundler", 
  },
  "include": [
    "**/.vitepress/**/*.ts",
    "**/.vitepress/**/*.mts",
    "**/.vitepress/**/*.vue"
  ],
  "exclude": [
    "node_modules"
  ]
}

其中的

  • module 选项指定了 JavaScript/TypeScript 的模块格式,Nolebase Integrations 默认使用与 ESNext 相兼容的模块格式。
  • moduleResolution 选项指定了模块解析策略,因为所有的 Nolebase Integrations 插件都遵循最新的 ECMAScript 规范与导出声明,如果你遇到了 Cannot find module ... or its corresponding type declarations 的错误,你可能需要将 moduleResolution 设置为 Bundler

如果你想要更多的配置,可以参考下面的示例:

jsonc
{
  "compilerOptions": {
    "jsx": "preserve",
    "lib": [
      "DOM",
      "ESNext"
    ],
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "resolveJsonModule": true,
    "strict": true,
    "strictNullChecks": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noEmit": true,
    "removeComments": false,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "verbatimModuleSyntax": true,
    "skipLibCheck": true
  },
  "include": [
    "**/.vitepress/**/*.ts",
    "**/.vitepress/**/*.mts",
    "**/.vitepress/**/*.vue"
  ],
  "exclude": [
    "node_modules"
  ]
}
typescript
import {  } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default ({
  : { 
    : { 
      : [ 
        // @rive-app/canvas is a CJS/UMD module, so it needs to be included here
        // for Vite to properly bundle it.
        '@nolebase/vitepress-plugin-enhanced-readabilities > @nolebase/ui > @rive-app/canvas', 
      ], 
      : [ 
        '@nolebase/vitepress-plugin-enhanced-readabilities/client', 
      ], 
    }, 
    : { 
      : [ 
        // If there are other packages that need to be processed by Vite, you can add them here.
        '@nolebase/vitepress-plugin-enhanced-readabilities', 
      ], 
    }, 
  }, 
  : 'en',
  : 'Site Name',
  : {
    // rest of the options...
  }
  // rest of the options...
})

You might have configured the separated Vite configuration file (e.g. vite.config.ts) if you are already mastered Vite. In this case, you could ignore the above configuration and add the following configuration to your Vite configuration file:

If you've never seen a colored diff before

This is a markup rule for displaying diff in the user interface (UI).

Red parts usually represents the lines you are going to remove, commonly appeared with a Minus sign -, or you could simply understand it as: this line will be removed.

Green parts usually represents the lines you are going to add, commonly appeared with a Plus sign +, or you could simply understand it as: this line will be added.

To learn more about diff, you can check out this answer about the history of diffutils and Git's documentation

是 TypeScript 用户吗?

至少需要配置下面的几个选项:

jsonc
{
  "compilerOptions": {
    "module": "ESNext", 
    "moduleResolution": "Bundler", 
  },
  "include": [
    "**/.vitepress/**/*.ts",
    "**/.vitepress/**/*.mts",
    "**/.vitepress/**/*.vue"
  ],
  "exclude": [
    "node_modules"
  ]
}

其中的

  • module 选项指定了 JavaScript/TypeScript 的模块格式,Nolebase Integrations 默认使用与 ESNext 相兼容的模块格式。
  • moduleResolution 选项指定了模块解析策略,因为所有的 Nolebase Integrations 插件都遵循最新的 ECMAScript 规范与导出声明,如果你遇到了 Cannot find module ... or its corresponding type declarations 的错误,你可能需要将 moduleResolution 设置为 Bundler

如果你想要更多的配置,可以参考下面的示例:

jsonc
{
  "compilerOptions": {
    "jsx": "preserve",
    "lib": [
      "DOM",
      "ESNext"
    ],
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "resolveJsonModule": true,
    "strict": true,
    "strictNullChecks": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noEmit": true,
    "removeComments": false,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "verbatimModuleSyntax": true,
    "skipLibCheck": true
  },
  "include": [
    "**/.vitepress/**/*.ts",
    "**/.vitepress/**/*.mts",
    "**/.vitepress/**/*.vue"
  ],
  "exclude": [
    "node_modules"
  ]
}
typescript
import {  } from 'vite'

export default (() => {
  return {
    : {
      : [ 
        // @rive-app/canvas is a CJS/UMD module, so it needs to be included here
        // for Vite to properly bundle it.
        '@nolebase/vitepress-plugin-enhanced-readabilities > @nolebase/ui > @rive-app/canvas', 
      ], 
      : [ 
        '@nolebase/vitepress-plugin-enhanced-readabilities/client', 
        'vitepress'
      ], 
    },
    : { 
      : [ 
        // If there are other packages that need to be processed by Vite, you can add them here.
        '@nolebase/vitepress-plugin-enhanced-readabilities', 
      ], 
    }, 
    : [
      // other vite plugins...
    ],
    // other vite configurations...
  }
})

If you haven't configured any of the separated Vite configuration file (e.g. vite.config.ts) before but still want to have a try with the above configuration, you can create a vite.config.ts file in the root directory of your VitePress project and add the above configuration to it. (Don't forget to install vite through your package manager as well!)

Add plugin into the Theme options of VitePress

In VitePress's theme configuration file (note that it's not a configuration file, it's usually located at docs/.vitepress/theme/index.ts, file paths and extensions may be vary), import @nolebase/vitepress-plugin-enhanced-readabilities package and add it to the Layout section as a slot:

If you've never seen a colored diff before

This is a markup rule for displaying diff in the user interface (UI).

Red parts usually represents the lines you are going to remove, commonly appeared with a Minus sign -, or you could simply understand it as: this line will be removed.

Green parts usually represents the lines you are going to add, commonly appeared with a Plus sign +, or you could simply understand it as: this line will be added.

To learn more about diff, you can check out this answer about the history of diffutils and Git's documentation

是 TypeScript 用户吗?

至少需要配置下面的几个选项:

jsonc
{
  "compilerOptions": {
    "module": "ESNext", 
    "moduleResolution": "Bundler", 
  },
  "include": [
    "**/.vitepress/**/*.ts",
    "**/.vitepress/**/*.mts",
    "**/.vitepress/**/*.vue"
  ],
  "exclude": [
    "node_modules"
  ]
}

其中的

  • module 选项指定了 JavaScript/TypeScript 的模块格式,Nolebase Integrations 默认使用与 ESNext 相兼容的模块格式。
  • moduleResolution 选项指定了模块解析策略,因为所有的 Nolebase Integrations 插件都遵循最新的 ECMAScript 规范与导出声明,如果你遇到了 Cannot find module ... or its corresponding type declarations 的错误,你可能需要将 moduleResolution 设置为 Bundler

如果你想要更多的配置,可以参考下面的示例:

jsonc
{
  "compilerOptions": {
    "jsx": "preserve",
    "lib": [
      "DOM",
      "ESNext"
    ],
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "resolveJsonModule": true,
    "strict": true,
    "strictNullChecks": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noEmit": true,
    "removeComments": false,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "verbatimModuleSyntax": true,
    "skipLibCheck": true
  },
  "include": [
    "**/.vitepress/**/*.ts",
    "**/.vitepress/**/*.mts",
    "**/.vitepress/**/*.vue"
  ],
  "exclude": [
    "node_modules"
  ]
}
typescript
import {  } from 'vue'
import  from 'vitepress/theme'
import type {  as ThemeConfig } from 'vitepress'
import { 
  , 
  , 
} from '@nolebase/vitepress-plugin-enhanced-readabilities/client'

import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css'

import './styles/vars.css'
import './styles/main.css'

export const : ThemeConfig = {
  : ,
  : () => {
    return (., null, {
      // A enhanced readabilities menu for wider screens
      'nav-bar-content-after': () => (), 
      // A enhanced readabilities menu for narrower screens (usually smaller than iPad Mini)
      'nav-screen-content-after': () => (), 
    })
  },
  () {
    // other configurations...
  },
}

export default 

VitePress style glitched?

You may notice a slight misalignment in the style of the navigation bar after integrating the navigation bar component with social links configured, this is because VitePress native social links component have a negative 16 pixel right margin as deviation by default.

You can fix this by adding the following style to the .vitepress/theme/styles directory or to the main.css style file under the .vitepress/theme/styles folder:

css
.VPSocialLinks.VPNavBarSocialLinks.social-links {
  margin-right: 0;
}

If you don't have this file, you can create a main.css file and import this style file in the VitePress theme configuration file .vitepress/theme/index.ts:

typescript
import './styles/main.css'

Already have h() function being called after nav-bar-content-after or nav-screen-content-after?

If you have already configured other components for your nav-bar-content-after or nav-screen-content-after, you can work around this by rewriting them as arrays starting with [ and ending with ], as in the following writeup:

typescript
// Rest of the code...

export const Theme: ThemeConfig = {
  extends: DefaultTheme,
  Layout: () => {
    return h(DefaultTheme.Layout, null, {
      'nav-bar-content-after': () => h(OtherComponent), // Your other nav components
      'nav-bar-content-after': () => [ 
        h(OtherComponent), // Your other nav components
        h(NolebaseEnhancedReadabilitiesMenu), // Enhanced Readabilities menu
      ], 
      'nav-screen-content-after': () => h(OtherComponent), // Your other nav components
      'nav-screen-content-after': () => [ 
        h(OtherComponent), // Your other nav components
        h(NolebaseEnhancedReadabilitiesScreenMenu), // Enhanced Readabilities menu for small screens
      ], 
    })
  },
  enhanceApp({ app }) {
    // other configurations...
  },
}

export default Theme

Integrate on-demand

Caution

Configure on your own is for those who know and understand what they are doing. If you don't know what you are doing or encounter problems during configuration, please read and follow the Integrate with VitePress section.

The Enhanced Readabilities plugin exports the components it uses internally, so if you don't like the style and encapsulation of the default menu buttons, etc., you can use these components directly to freely configure your menu buttons:

Install as a Vue plugin

typescript
import {
   
} from '@nolebase/vitepress-plugin-enhanced-readabilities/client'
import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css'

If you are working on a VitePress and wanted to install it into Vue instance, you can do it like this:

typescript
import type {  as ThemeConfig } from 'vitepress'
import  from 'vitepress/theme'

import {  } from '@nolebase/vitepress-plugin-enhanced-readabilities/client'
import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css'

// Rest of the code...

export const : ThemeConfig = {
  : ,
  : () => {
    // Rest of the code...
  },
  ({  }) {
    .() 
  },
}

export default 

Of course you can also provide the relevant configuration directly when installing the plugin:

typescript
import type {  as ThemeConfig } from 'vitepress'
import  from 'vitepress/theme'

import type { Options } from '@nolebase/vitepress-plugin-enhanced-readabilities/client'
import {  } from '@nolebase/vitepress-plugin-enhanced-readabilities/client'
import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css'

export const : ThemeConfig = {
  : ,
  : () => {
    // Rest of the code...
  },
  ({  }) {
    .(, {  
      : {  
        'zh-CN': {  
          : {  
            : '阅读增强插件',  
          }  
        },  
        'en': {  
          : {  
            : 'Enhanced Readabilities Plugin',  
          }  
        }  
      }  
    } as Options) 
  },
}

export default 

For more information on configuration, see Configuration.

Import layout switching components on demand

typescript
import {
  ,  
  ,  
} from '@nolebase/vitepress-plugin-enhanced-readabilities/client'

Import spotlight components on demand

typescript
import {
  ,  
  , 
} from '@nolebase/vitepress-plugin-enhanced-readabilities/client'

Configuration

The Enhanced Readabilities plugin currently provides configuration options related to Internationalization and Help Tooltip.

Configure in VitePress

Since VitePress doesn't provide more functionality for the default theme to extend the default theme configuration, it is not friendly to the type checking and maintenance of the configuration if we directly modify the major VitePress configuration object to provide options for the plugin.

Therefore we offer a way with Vue's dependency injection to provide options and configuration for the plugin:

If you've never seen a colored diff before

This is a markup rule for displaying diff in the user interface (UI).

Red parts usually represents the lines you are going to remove, commonly appeared with a Minus sign -, or you could simply understand it as: this line will be removed.

Green parts usually represents the lines you are going to add, commonly appeared with a Plus sign +, or you could simply understand it as: this line will be added.

To learn more about diff, you can check out this answer about the history of diffutils and Git's documentation

typescript
import type {  as ThemeConfig } from 'vitepress'
import  from 'vitepress/theme'

import type { Options } from '@nolebase/vitepress-plugin-enhanced-readabilities/client'
import {  } from '@nolebase/vitepress-plugin-enhanced-readabilities/client'

export const : ThemeConfig = {
  : ,
  : () => {
    // Rest of the code...
  },
  ({  }) {
    // Rest of the code...

    .(, { 
      // Configuration...
    } as Options) 

    // Rest of the code...
  },
}

For more information on internationalization configuration, see Internationalization.

Options inside

Complete configurable options
typescript
/**
 * Options
 */
export interface Options {
  /**
   * Internationalization configuration
   *
   * When configuring, please configure according to the language code configured in
   * VitePress internationalization configuration. In the following configuration, 'en'
   * and 'zh-CN' are the language codes configured in VitePress internationalization
   * configuration.
   *
   * @default undefined
   * @example
   * ```ts
   * {
   *  locales: {
   *    'en': {
   *      title: {
   *       title: 'Reading Mode',
   *      titleAriaLabel: 'Reading Mode',
   *    },
   *    'zh-CN': {
   *       title: {
   *         title: '阅读模式',
   *         titleAriaLabel: '阅读模式',
   *     },
   *   }
   * }
   * ```
   */
  ?: <string, Locale>
  /**
   * Layout switch configuration
   */
  ?: {
    /**
     * Disable layout switch help tooltip
     *
     * @default false
     */
    ?: boolean
    /**
     * Default mode for layout switch
     *
     * @default LayoutMode.Original (3)
     */
    ?: 
    /**
     * Content layout max width slider configuration
     */
    ?: {
      /**
       * Disable content layout max width help tooltip
       *
       * @default false
       */
      ?: boolean
      /**
       * Default percentage of content layout max width
       *
       * @default 100 (100%)
       */
      ?: number
    }
    /**
     * Page layout max width slider configuration
     */
    ?: {
      /**
       * Disable page layout max width help tooltip
       *
       * @default false
       */
      ?: boolean
      /**
       * Default percentage of page layout max width
       *
       * @default 800 (80%)
       */
      ?: number
    }
  }
  /**
   * Spotlight configuration
   */
  ?: {
    /**
     * Disable spotlight help tooltip
     *
     * @default false
     */
    ?: boolean
    /**
     * Spotlight hover block color
     *
     * @default 'rgb(240 197 52 / 10%)'
     */
    ?: string
    /**
     * Default toggle for spotlight
     *
     * @default false
     */
    ?: boolean
    /**
     * Default style for spotlight
     *
     * @default SpotlightStyle.Aside (2)
     */
    ?: 
  }
}

Internationalization

Caution

The Enhanced Readabilities plugin does not use vue-i18n as an i18n toolkit since most of VitePress probably uses VitePress's internationalization features for internationalization, so it is impossible to override the fields of the localized text of the Enhanced Readabilities plugin with vue-i18n, but you can achieve it with the locales field in Configuration.

The Enhanced Readabilities plugin supports internationalization by default, with English and Simplified Chinese as supported languages by default.

You can override the plugin's localized text through configuration, and before you start, you need to understand how VitePress is internationalized: Internationalization of VitePress. The Enhanced Readabilities plugin reads the VitePress language field by default, so you'll need to be careful to keep the internationalized language code the same as the VitePress language code when configuring it.

Configure in VitePress

In the Configuration section, we've learned how to provide configuration options for the Enhanced Readabilities plugin in VitePress, and we can configure internationalization by adding the locales field to the configuration options:

If you've never seen a colored diff before

This is a markup rule for displaying diff in the user interface (UI).

Red parts usually represents the lines you are going to remove, commonly appeared with a Minus sign -, or you could simply understand it as: this line will be removed.

Green parts usually represents the lines you are going to add, commonly appeared with a Plus sign +, or you could simply understand it as: this line will be added.

To learn more about diff, you can check out this answer about the history of diffutils and Git's documentation

typescript
import type {  as ThemeConfig } from 'vitepress'
import  from 'vitepress/theme'

import type { Options } from '@nolebase/vitepress-plugin-enhanced-readabilities/client'
import {  } from '@nolebase/vitepress-plugin-enhanced-readabilities/client'

// Rest of code...

export const : ThemeConfig = {
  : ,
  : () => {
    // Rest of code...
  },
  ({  }) {
    // Rest of code...

    .(, {
      : { // i18n
        'zh-CN': { // configure for Simplified Chinese
          : { 
            : '阅读增强插件', 
          } 
        }, 
        'en': { // configure for English
          : { 
            : 'Enhanced Readabilities Plugin', 
          } 
        } 
      } 
    } as Options)

    // Rest of code...
  },
}

Locales options

Complete internationalization field options
typescript
/**
 * Locale
 */
export interface Locale {
  /**
   * Title
   *
   * Used to configure the title of the menu located on the top-right corner of the page.
   */
  ?: {
    /**
     * Title text
     */
    ?: string
    /**
     * Title aria-label
     */
    ?: string
  }
  /**
   * Layout switch configuration
   *
   * Used to configure the layout switch menu.
   */
  ?: {
    /**
     * Title text
     */
    ?: string
    /**
     * Title aria-label
     */
    ?: string
    /**
     * Title descriptive help message
     */
    ?: string
    /**
     * Title warning message for navigation menu in small screen
     */
    ?: string
    /**
     * Expand all option text
     */
    ?: string
    /**
     * Expand all option aria-label
     */
    ?: string
    /**
     * Expand all option help message
     */
    ?: string
    /**
     * Sidebar adjustable only option text
     */
    ?: string
    /**
     * Sidebar adjustable only option aria-label
     */
    ?: string
    /**
     * Sidebar adjustable only option help message
     */
    ?: string
    /**
     * Both width adjustable option text
     */
    ?: string
    /**
     * Both width adjustable option aria-label
     */
    ?: string
    /**
     * Both width adjustable option help message
     */
    ?: string
    /**
     * Original option
     */
    ?: string
    /**
     * Original option aria-label
     */
    ?: string
    /**
     * Original option help message
     */
    ?: string

    /**
     * Content layout max width slider configuration
     */
    ?: {
      /**
       * Title text
       */
      ?: string
      /**
       * Title aria-label
       */
      ?: string
      /**
       * Title descriptive help message
       */
      ?: string
      /**
       * Title warning message for navigation menu in small screen
       */
      ?: string
      /**
       * Content layout max width slider functionality title in help tooltip popup
       */
      ?: string
      /**
       * Content layout max width slider functionality aria-label in help tooltip popup
       */
      ?: string
      /**
       * Content layout max width slider functionality descriptive help message in help tooltip popup
       */
      ?: string
    }
    /**
     * Page layout max width slider configuration
     */
    ?: {
      /**
       * Title text
       */
      ?: string
      /**
       * Title aria-label
       */
      ?: string
      /**
       * Title descriptive help message
       */
      ?: string
      /**
       * Title warning message for navigation menu in small screen
       */
      ?: string
      /**
       * Page layout max width slider functionality title in help tooltip popup
       */
      ?: string
      /**
       * Page layout max width slider functionality aria-label in help tooltip popup
       */
      ?: string
      /**
       * Page layout max width slider functionality descriptive help message in help tooltip popup
       */
      ?: string
    }
  }
  /**
   * Spotlight configuration
   */
  ?: {
    /**
     * Title text
     */
    ?: string
    /**
     * Title aria-label
     */
    ?: string
    /**
     * Title help message
     */
    ?: string
    /**
     * Title warning message for navigation menu in small screen
     */
    ?: string
    /**
     * Option: On text
     */
    ?: string
    /**
     * Option: On aria-label
     */
    ?: string
    /**
     * Option: On help message
     */
    ?: string
    /**
     * Option: Off text
     */
    ?: string
    /**
     * Option: Off aria-label
     */
    ?: string
    /**
     * Option: Off help message
     */
    ?: string
    ?: {
      /**
       * Title text
       */
      ?: string
      /**
       * Title aria-label
       */
      ?: string
      /**
       * Title help message
       */
      ?: string
      /**
       * Title warning message for navigation menu in small screen
       */
      ?: string
      /**
       * Option: Under text
       */
      ?: string
      /**
       * Option: Under aria-label
       */
      ?: string
      /**
       * Option: Under help message
       */
      ?: string
      /**
       * Option: Aside text
       */
      ?: string
      /**
       * Option: Aside aria-label
       */
      ?: string
      /**
       * Option: Aside help message
       */
      ?: string
    }
  }
}

Accessibility

The Enhanced Readabilities plugin provides accessibility support by default. You can override accessible labels (aria-label) via Configuration in the same way as Internationalization, see Locales Options for a description of what labels can be configured for accessibility.

Problems? Let's Troubleshoot

Encountered Cannot find module ... or its corresponding type declarations error?

If you are encountering this error with Nolebase Integrations packages inside of .ts or .vue files, you may need to configure the moduleResolution option in your tsconfig.json file.

jsonc
{
  "compilerOptions": {
    "module": "ESNext", 
    "moduleResolution": "Bundler", 
  },
  "include": [
    "**/.vitepress/**/*.ts",
    "**/.vitepress/**/*.mts",
    "**/.vitepress/**/*.vue"
  ],
  "exclude": [
    "node_modules"
  ]
}

If the error persists, please submit a GitHub issue for further assistance and troubleshooting.

The requested module vitepress does not provide an export named useData or The requested module vitepress does not provide an export named useRoute

If you have already configured your VitePress that working properly, you might encounter the above error when you try to install and integrate the Enhanced Readabilities plugin for the first time.

This is part of the command output, use it as reference if you want:

shell
build error:
file://Docs/dist/index.js:2
import { useData as Fe, withBase as tt, useRoute as nt } from "vitepress";
         ^^^^^^^
SyntaxError: The requested module 'vitepress' does not provide an export named 'useData'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

However, it's ok if the error message is saying either useData or useRoute, you could still use some of the following steps to troubleshoot it and get some references.

Such errors are usually caused by the following reasons:

You are using an older version of VitePress (or incompatible)

You might have actually installed and used a old version of VitePress that didn't support the useData and useRoute composables long before.

To check this, you can check the version of VitePress by running the script docs:dev with the following command:

shell
pnpm docs:dev
shell
npm run docs:dev
shell
yarn docs:dev

The output might look like this:

shell
> @nolebase/integrations-docs@ docs:dev /nolebase/integrations/docs
> vitepress dev


  vitepress v1.0.0-rc.12

  Local:   http://localhost:5173/
  Network: use --host to expose
  press h to show help

The line vitepress v1.0.0-rc.12 indicates your VitePress version as v1.0.0-rc.12, by default, Nólëbase Integrations (include Enhanced Readabilities and the other integrations) requires at least vitepress v1.0.0-beta.1, if you are using some of the versions long before (e.g. alpha), you have to upgrade your VitePress to the nearest compatible version to resolve this issue.

You might missed the configurations in section Add plugin-specific options into configurations of Vite

If you incautiously missed the configurations in section Add plugin-specific options into configurations of Vite, the reference to vitepress inside of the Enhanced Readabilities plugin might be broken or miss-processed when building your VitePress site. So you have to configure it accurately by following the section Add plugin-specific options into configurations of Vite accordingly.

Contributors

Changelog