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

improve: missing env properties for Content Loader when render is specified #4349

Closed
nekomeowww opened this issue Nov 10, 2024 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@nekomeowww
Copy link

nekomeowww commented Nov 10, 2024

Summary

For general VitePress page renders, properties of env are available for markdown-it plugins to peek file path related info:

// reset env before render
const env: MarkdownEnv = {
path: file,
relativePath,
cleanUrls,
includes,
realPath: fileOrig,
localeIndex
}
const html = md.render(src, env)

However, for content loader, if specified such

export default createContentLoader('/**/*.md', {
  render: true,
  transform() {
    return []
  },
})

content loader function, with our Lazy loading blurred thumbnails | Nólëbase Integrations markdown-it plugin where env.path and env.relativePath are required, since users are not allowed to toggle these unsupported markdown-it plugins for content loaders, they will not be able to use content loaders with markdown-it-unlazy-img together.

I found the code here, for content loaderss, within the render function, env properties are not injected as what VitePress's render would do:

const html = render ? md.render(src) : undefined

Proposal

  • Add env properties
  • Allow users to reconfigure md.use
@brc-dd brc-dd added the bug Something isn't working label Nov 10, 2024
@brc-dd
Copy link
Member

brc-dd commented Nov 10, 2024

Duplicate of #4331

Please track it instead. We actually need a bunch of refactoring for this to work correctly. I'll do it next when I get time.

@brc-dd brc-dd marked this as a duplicate of #4331 Nov 10, 2024
@brc-dd brc-dd closed this as completed Nov 10, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants