docsifyjs / docsify

🃏 A magical documentation site generator.
https://docsify.js.org
MIT License
27.78k stars 5.68k forks source link

feat: The timing of the `doneEach` hook call for the cover #2427

Open YiiGuxing opened 6 months ago

YiiGuxing commented 6 months ago

Summary

The doneEach hook function for the cover should be called after the cover page HTML has been appended to the DOM.

Related issue, if any:

What kind of change does this PR introduce?

Feature

For any code change,

Does this PR introduce a breaking change?

No

Tested in the following browsers:

vercel[bot] commented 6 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docsify-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2024 2:17pm
jhildenbiddle commented 5 months ago

Thanks of this, @YiiGuxing. Can you add some tests to test/e2e/plugins.test.js to verify the new behavior? Thx!

YiiGuxing commented 5 months ago

@jhildenbiddle. Completed. Please review.

YiiGuxing commented 5 months ago

@jhildenbiddle, I found that this PR does not work in the asynchronous mode of marked.js. I am fixing it, please wait for my patch.

YiiGuxing commented 5 months ago

@jhildenbiddle, The fact that the cover doesn't work in asynchronous mode on marked.js isn't due to this PR, it's the same problem on the develop branch: setting markdown: { async: true } will cause the cover and the sidebar to malfunction. The new commit ensures that the cover works properly, but there are still issues with the sidebar. The new commits also add support for embedding files in the cover and fix an issue where the doneEach hook might not be called.

Additionally, regarding the beforeEach and afterEach hooks for the cover, these hooks are called twice when the cover and the homepage are on the same page. Since we cannot intuitively determine the target of the hook within the hook function, I have not implemented them.