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: more elegant way to improve vitepress-plugin-highlight-targeted-heading #68

Open
BeiyanYunyi opened this issue Jan 27, 2024 · 1 comment
Labels
enhancement New feature or request upstream Blocked by or related to upstream dependencies

Comments

@BeiyanYunyi
Copy link
Contributor

BeiyanYunyi commented Jan 27, 2024

We can implement the highlight effect with the :target selector instead, without js.

Example code

Live demo:

Highlight headings within the page Click the links in table of contents in sidebar to see the highlight effect.

Highlight headings across pages

@nekomeowww
Copy link
Member

nekomeowww commented Jan 27, 2024

Thanks for the feedbacks!

I do know it is possible to implement such functionalities through :target selector instead of the current implementation.

Unfortunately, I have performed the experiment against this long before the publication of this plugin. The results shown that the functionalities of :target selector would be broken when the history (or router) has taken control by the current VitePress's implementation of vue router.

Therefore, the :target selector will be dismissed once loaded and only can be triggered at the very first beginning of page load since it is SSG rendered pages where the router haven't yet existed.

I have included both the reproduction repo, steps and workarounds in this VitePress issue for such breaking changed behaviors here vuejs/vitepress#2984 (comment) . (Please kindly take a look into this issue if you'd have time)

@nekomeowww nekomeowww added bug Something isn't working question Further information is requested upstream Blocked by or related to upstream dependencies and removed question Further information is requested labels Jan 27, 2024
@nekomeowww nekomeowww changed the title Improve: More elegant way to improve vitepress-plugin-highlight-targeted-heading improve: more elegant way to improve vitepress-plugin-highlight-targeted-heading Mar 6, 2024
@nekomeowww nekomeowww added enhancement New feature or request and removed bug Something isn't working labels Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upstream Blocked by or related to upstream dependencies
Projects
None yet
Development

No branches or pull requests

2 participants