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

fix: detect public folder for dead link #290

Merged
merged 2 commits into from
May 27, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/node/markdownToVue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export function createMarkdownToVueRenderFn(
? url.slice(1)
: path.relative(root, path.resolve(dir, url))
)
if (!pages.includes(resolved)) {
if (
!pages.includes(resolved) &&
!fs.existsSync(path.resolve(dir, 'public', `${resolved}.html`))
Copy link
Member

@antfu antfu Apr 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use config.publicDir

https://vitejs.dev/config/#publicdir

Copy link
Contributor Author

@YunYouJun YunYouJun Apr 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thanks. But i can not find how to use vite config in vitepress.
Can you give me a hint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can i get resolvedViteConfig in markdownToVue.ts?
It seems that there is not a global configuration exported.
Should there be a better solution to get some global configuration in the function?

build(resolveViteConfig(false)),

export function createMarkdownToVueRenderFn(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get it using https://vitejs.dev/guide/api-plugin.html#configresolved in plugin.ts and pass it over

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I submitted a new commit that uses config.publicDir instead of the 'public' string.

) {
console.warn(
chalk.yellow(
`\n(!) Found dead link ${chalk.cyan(
Expand Down