Skip to content

Parametrize pattern of pages resolved #1700

Closed
adamlaska/osmos-cosmos-sdk
#5
@eduardcotmrf

Description

@eduardcotmrf

Feature request

Right now the pattern configuration of what files should be resolved as pages is hardcoded in core module of vuepress (APP.js line 319). The intention it's to open the door to parametrizing this pattern configuration from the siteConfig.

What problem does this feature solve?

To remove folders of specific files matching some pattern from the final vuepress site. A common scenario is where you are documenting a project that has a bunch of vue files you don't want to expose as documentation.

With this approach we could change this pattern:
['**/*.md', '**/*.vue', '!.vuepress', '!node_modules']

To have something like:
['**/*.md', '!.vuepress', '!node_modules']

Or like this:
['**/*.md', '**/*.vue', '!**/vue-folder/*.vue', '!.vuepress', '!node_modules']

How should this be implemented in your opinion?

The proposal it's to add the logic in resolvePages method to retrieve the pattern from siteConfig, if not use the default one:

  async resolvePages () {
    // resolve pageFiles
    const patterns = this.siteConfig.patterns ? this.siteConfig.patterns : ['**/*.md', '**/*.vue']
    patterns.push('!.vuepress', '!node_modules');

So it can be easily configured from config.js:

module.exports = {
  title: 'Hello VuePress',
  description: '# Hello, VuePress!',
  dest: 'vuepress',
  base: 'vuepress',
  patterns: ['**/*.md', '**/*.vue', '!**/deploy.*'],
  head: [
    ['link', { rel: 'icon', href: '/logo.png' }]
  ]
}

Are you willing to work on this yourself?

Yes, it's a necessity we have in our current project and i would like to work on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions