hugo-theme-codex icon indicating copy to clipboard operation
hugo-theme-codex copied to clipboard

Add sidenote support

Open dgnicholson opened this issue 5 years ago β€’ 7 comments

Hi folks.

I've been playing with adding sidenote support. My current implementation puts sidenotes to the right of the text on wider screens:
image

On mobile, sidenotes appear inline.

image

They are added via shortcode. For example:

{{< sidenote note="Ut quis turpis quis enim rhoncus vehicula vel et neque. Nullam porta nunc rutrum velit faucibus interdum. Cras in quam non leo mattis feugiat. Fusce interdum nisl nibh, quis pellentesque turpis vehicula sit amet." >}}

I may also add an option for margin notes which leave the number out entirely.

The bulk of the work done, but need to iron out a few things--mainly having it play nice with the ToC. If this is something that fits the project, I can add a PR when it's ready.

dgnicholson avatar Jul 29 '20 02:07 dgnicholson

I actually really dig on this. I'm wondering (I'm on mobile) if it's possible to have side notes render at the end of a post. Even if it's just on mobile. But I imagine that would change the implementation drastically. I've noticed blogs include this type of thing towards the end.

But it's just a suggestion. @dgnicholson this project is as much yours as it is mine. If you think it works well enough on your end then it should benefit this project πŸš€

jakewies avatar Jul 29 '20 04:07 jakewies

@jakewies Thanks for the idea! I'll have a look at that and see what's involved. Another solution I was thinking of was hiding the notes on mobile until the user clicks the superscript numeral which would then expand it inline, but I figured the target is very small and might be too easily overlooked.

dgnicholson avatar Jul 29 '20 20:07 dgnicholson

Just want to chime in with my support for this! Thanks for working on this @dgnicholson

aareet avatar Sep 24 '20 20:09 aareet

@dgnicholson any update? Would love to get this in the project. No pressure!

jakewies avatar Oct 18 '20 15:10 jakewies

@jakewies still on my to-do list due to Lifeβ„’, but not forgotten. I dusted it off today and the functionality is close to being done, except for a counting bug and issues with the sidenote text interacting with the ToC. I'm thinking the latter issue can be addressed easily enough by showing the sidenotes inline once the width of the window starts causing overlapping with the TOC. I'd also like to investigate adding a footnote option but if it's too much work I'll add it a later.

With additional style tweaks, cleanup, testing, and docs I figure I'll have a PR ready sometime in November.

dgnicholson avatar Oct 18 '20 20:10 dgnicholson

Awesome! Totes understand about Life, it took me a few months to get some time for this project this weekend. If it makes the structure of this feature easier, implementing as strictly footnotes would be pretty great too. Just a thought.

jakewies avatar Oct 19 '20 14:10 jakewies

Quick Update. After a few iterations, I've struggled to get the design work with the way the ToC is implemented. For situations where the ToC overlaps the sidenotes while scrolling I've tried various solutions like changing the background opacity of the ToC to blur out the sidenotes but that and my other solutions look kinda janky.

The only thing I can think of is to have the sidenote appear inline when the ToC overlaps while scrolling down the page. I'll investigate if I can get this to work with my implementation and update either way.

Note that I've also ended up enhancing the markdown footnotes--see PR: https://github.com/jakewies/hugo-theme-codex/pull/144

dgnicholson avatar Dec 09 '20 03:12 dgnicholson