hendricius / the-sourdough-framework

Open source book dedicated to helping you to make the best possible sourdough bread at home.
https://breadco.de/book
Creative Commons Attribution Share Alike 4.0 International
2.57k stars 128 forks source link

Permalinks for website section heads #272

Closed sha1sum closed 8 months ago

sha1sum commented 8 months ago

This uses vanilla JavaScript to cycle through section headings and add a unicode chain đź”— link for permalinks to take one directly to it. Mostly this is useful when someone has already been scrolling pretty far and they find what they're looking for and want a link straight to it without scrolling back to the ToC to find it again.

See "Baker's Math" heading in this screenshot:

image
cedounet commented 8 months ago

Looks useful… can we also have that for tables/figures and my favourite in this book flowcharts ?

thanks.

hendricius commented 8 months ago

@sha1sum lovely, thank you! I can transfer this into the html directly if you like.

Could we have a copy to clipboard thingy when you click it, it's copied to the clipboard. Or do you think it's too intrusive?

sha1sum commented 8 months ago

@hendricius I'm not at all familiar with this setup so I opted for the script-only version like we talked about in Discord. Feel free to move it. Copying to clipboard is possible. Just have to be a little clever with the text that's copied because it needs to be a combination of the current URL with no anchors plus the anchor for what you're linking. Let me know if that's something you want.

sha1sum commented 8 months ago

Looks useful… can we also have that for tables/figures and my favourite in this book flowcharts ?

thanks.

There is no id to anchor to for many of those elements. There would have to be some sort of anchor added into the markup that can be linked to, which I'm sure can be done if you would like to do so.

cedounet commented 8 months ago

Looks useful… can we also have that for tables/figures and my favourite in this book flowcharts ? thanks.

There is no id to anchor to for many of those elements. There would have to be some sort of anchor added into the markup that can be linked to, which I'm sure can be done if you would like to do so.

I understand nothing about web… but how does the link on the table of contents for list of figures work if there is no anchor?

that being said if that is too much work, then I am not overly bothered about not having it.

thanks.

hendricius commented 8 months ago

Thanks! Noted. Will merge this for now and then create a followup PR with your comments.

hendricius commented 8 months ago

@cedounet there is an anchor in the via the IDs for most of the content created in the build process. I'll see if I can find one too for the the flowcharts etc.

sha1sum commented 8 months ago

Actually I guess there is an ID in them that I just noticed. Probably could do something similar with them, but I'm guessing it's probably better to move it into the markup first before adding those.