Skip to content
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

Link to section #81

Open
sean-smith opened this issue Apr 6, 2023 · 2 comments
Open

Link to section #81

sean-smith opened this issue Apr 6, 2023 · 2 comments

Comments

@sean-smith
Copy link

sean-smith commented Apr 6, 2023

Would be great to add a click to create an anchor link to link to subsections. Here's an example:

image

I would love it if you could click on the ##Setup and get an anchor link like: https://swsmith.cc/posts/cost-explorer-pcluster.html#setup

The id is already setup so the only feature is to add this as a link to any headers in markdown.

@sean-smith
Copy link
Author

Ok, I can get the behaviour I want with:

{{< rawhtml >}}
<a href='#setup'><h2>Setup</h2></a>
{{< /rawhtml >}}

Instead of:

## Setup

Obviously it would be ideal if this was done at the markdown layer so I don't have to go through and change all my section headers.

Any pointers on how to do that? Basically override the rendering of h1,h2,h3... headers to render as a link

@sean-smith
Copy link
Author

Ok I implemented this on my site using some custom js, this looks like:

image

Example: https://swsmith.cc/posts/efa-best-practices.html#what-version-is-best

The code looks like:

sean-smith/swsmith.cc@ea2ac86

If anyone is interested I'll open a pull request to contribute this back upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant