-
-
Notifications
You must be signed in to change notification settings - Fork 77
[Solo] Add anchor link to content headings #2
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
base: main
Are you sure you want to change the base?
Conversation
Clicking heading link icon now copies URL to clipboard
Move local anchor link feature (heading copy-to-clipboard buttons) into custom.css and custom.js to minimize merge conflicts when rebasing from upstream TryGhost/Solo. - Create assets/css/custom.css with anchor link styling - Create assets/js/custom.js with anchor link functionality - Add @import "custom.css" to screen.css - Update gulpfile.js to conditionally include custom.js in build - Remove customizations from screen.css and main.js 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| anchor.addEventListener('click', async (e) => { | ||
| e.preventDefault(); | ||
| const url = new URL(window.location.href); | ||
| url.hash = heading.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anchor links fail for headings without IDs
The code sets url.hash = heading.id without checking if the heading has an id attribute. If a heading lacks an id, the copied URL will end with just #, which won't navigate to the intended section when shared. The anchor button is still added to such headings, potentially confusing users who expect the copied link to work.
This change adds anchor links to post headings, enabling you to share deep links to your articles so that people can navigate directly to the relevant content you're trying to share. The anchor link is hidden until you hover over (or touch) the heading, and once it's displayed you can copy the link to share it with someone else.
Here's a demo of what it looks like:
solo-heading-anchor-demo.mp4
And I'm hosting a live demo on my personal website which you can see here: https://evanw.com/2021-my-year-in-reading/#the-stats
This feature is really useful when you write longer-form content and want to share a specific section with someone, or if you're trying to link to specific sections within your own content.
If there are any questions or concerns about this change, please let me know. Thanks for the consideration!
Note
Introduces shareable deep links for article sections.
.gh-content h1–h6inassets/built/main.min.js; on click copies the heading URL to clipboard and shows tooltip feedback.anchor-linkstyles and tooltip/animation rules inassets/built/screen.css; ensures visibility on hover/touch.gitignoreextended (e.g.,robots.txt,node_modules/, yarn files)Written by Cursor Bugbot for commit 455ecc1. This will update automatically on new commits. Configure here.