←back to thread

Next.js is infuriating

(blog.meca.sh)
1033 points Bogdanp | 3 comments | | HN request time: 0.648s | source
Show context
ddanieltan ◴[] No.45100963[source]
A bit of a tangent, but how do you implement the feature when I highlight text on this blog, I get an option to generate a unique link directly to what I highlighted?
replies(1): >>45101217 #
1. OtherShrezzing ◴[] No.45101217[source]
Each paragraph/element has a unique ID, starting at 0, incrementing by 1. You originally land at the page https://blog.meca.sh/3lxoty3shjc2z . When you create a link, you're linking instead to a different page at https://blog.meca.sh/3lxoty3shjc2z/l-quote/64_25-65_174#64 . The format of the extra link metadata is `64_25-65_174#64`, which means:

- Start the highlight on the 64th element/paragraph. Inside of that paragraph, start from the 25th character.

- End the highlight on the 65th element. Inside of that element, end at the 174th character.

- Scroll the user to element #64 on page load.

They've then got some code on the page to add a highlighted span starting and ending at those points.

If the site maintainer is here: For me, the links are currently broken, as they should link to https://blog.meca.sh/3lxoty3shjc2z/l-quote/64_25-65_174#64, but currently link to https://blog.meca.sh/3lxoty3shjc2z/l-quote/64_25-65_174#64_2..., and `64_25` isn't a valid id on page-load.

replies(2): >>45104523 #>>45105284 #
2. dminik ◴[] No.45104523[source]
The blog itself is build on leaflet.pub.

I'll take a look and file an issue.

3. dminik ◴[] No.45105284[source]
Ok, I think I can reproduce it by starting the selection from the end of the previous line.

I've reported the issue here: https://github.com/hyperlink-academy/leaflet/issues/196