swiftlang/swift-org-website

Adding anchors to all sections on pages

Closed this issue · 4 comments

Is your feature request related to a problem? Please describe

When going to https://www.swift.org/community/, I'd like to copy the anchor to the page section for an easy copy and paste. I know that I can add "#" to the url for the major sections (example: swift.org/community/#communication) but it would be nice to have the link icon next to the sections at scroll over.

I'd like if the sub-sections were treated the same and they don't have an anchor right now at all.
Example: I find myself having to point to the Core Team's contact us on the forums link a good amount recently. It would be great if there is an anchor that would point directly to the Core Team section.

Describe the solution you'd like

Anchor links for sections and subsections alike next to the titles for easy copy and pasting.

Hey!
I was able to get a working solution for this issue, as demonstrated in the following video:

Screen.Recording.2024-01-30.at.1.24.37.PM.mov

I used this repo to add anchors to the headings. It could have been done using javascript itself from scratch, but using this repo seemed to be an easy way to implement anchors site-wide without changing a lot of things, and it works even with javascript disabled in the browser. I am not sure whether it'd be fine to include a third-party package, though it is MIT-licensed. Still, I'd like to hear your thoughts on this.

Here's a link to my fork to test it out: https://sow-ib.vercel.app/community

cc @alexandersandberg

Thanks for giving this a go, @ishaanbedi!

I think it would be nice to only show these anchors when the heading is hovered or focused. What do you think?

Hi @alexandersandberg !

I think it would be nice to only show these anchors when the heading is hovered or focused. What do you think?

That does sound better.

After a bit of changes and modifications to code, I was able to implement it:

Screen.Recording.2024-02-06.at.8.25.31.AM.mov

Here's a link to my fork to test it out: https://sow-ib.vercel.app/contributing

This looks great! Feel free to open a PR and we can continue to discuss it there. 🙂