Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OramaPlugin for vitepress, additional options. #742

Open
lazarusA opened this issue Jun 24, 2024 · 0 comments
Open

OramaPlugin for vitepress, additional options. #742

lazarusA opened this issue Jun 24, 2024 · 0 comments

Comments

@lazarusA
Copy link

Problem Description

At the moment, it looks like the plugin for vitepress only accepts analytics as a known options field. However, it looks like more options could be added, like schema, searchOptions, etc...

Proposed Solution

Currently, I was expecting this to work (without success) :

  vite: {
    plugins: [OramaPlugin({
      schema: {
        title: 'string',
        content: 'string',
        functionNames: 'string[]',
      },
      searchOptions: {
        boost: {
          title: 2,
          functionNames: 3,
        },
      },
      contentTransformer: (content) => {
        // This regex matches patterns like Name.func1 or Name1.name2.func2
        const regex = /(?:^|\s)((?:\w+\.)+(\w+))/g;
        const matches = [...content.content.matchAll(regex)];
        const functionNames = matches.map(match => match[2]); // Capture the last word after the period

        return {
          ...content,
          functionNames: [...new Set(functionNames)], // Remove duplicates
        }
      },
    })],
  },

any hints on how to achieved this? maybe a workaround?

Alternatives

No response

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant