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

Link Anything #2299

Open
dylanowen opened this issue Jan 26, 2024 · 1 comment
Open

Link Anything #2299

dylanowen opened this issue Jan 26, 2024 · 1 comment
Labels
C-enhancement Category: Enhancement or feature request

Comments

@dylanowen
Copy link
Contributor

dylanowen commented Jan 26, 2024

Problem

It is very useful with spec-md to be able to share a link to anything:
https://spec-md.com/#sel-EAHHFCAACCyFm2Q

It would be great if we could include this functionality in mdBook.

Proposed Solution

https://github.com/leebyron/spec-md/blob/main/src/client/linkSelections.js is the implementation for md-spec

https://github.com/WesleyAC/deeplinks is another implementation

Notes

No response

@dylanowen dylanowen added the C-enhancement Category: Enhancement or feature request label Jan 26, 2024
@dylanowen
Copy link
Contributor Author

dylanowen commented Jan 27, 2024

I managed to get deeplinks.js working with the existing html renderer configuration options however it was a bit clunky:

additional-js doesn't work as deeplinks.js is a module and additional-js doesn't account for that. additonal-js also doesn't copy over dependency imports. Maybe we could define a folder inside of theme that was copied over completely?

I was able to get this working by including a folder in my src directory as js which is copied over to the final book (any name works really). I then changed my theme/head.hbs to:

<script type="module" src="{{path_to_root}}/js/deeplinks.js"></script>

and included this additional-css:

* {
    /* Make sure when we scroll we don't hide our target under the menubar */
    scroll-margin-block-start: calc(var(--menu-bar-height) + 2em);
}

Screenshot 2024-01-26 at 17 29 54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

1 participant