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

add header links for the blog #155

Open
ix0rai opened this issue Sep 17, 2023 · 5 comments
Open

add header links for the blog #155

ix0rai opened this issue Sep 17, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@ix0rai
Copy link
Member

ix0rai commented Sep 17, 2023

blog posts should have a clickable permalink button that appears when the header is hovered, just like the one on the Team Listings page.
the permalink button on the team listings page

@ix0rai ix0rai added the enhancement New feature or request label Sep 17, 2023
@Akarys42
Copy link
Contributor

I remember looking at it back in the days, but I just couldn't figure out why rehype-autolink-headings didn't run on the blog posts. To me, all conditions appear satisfied, the headings are indeed headings and have a unique ID each.

rehypePlugins: [[rehypeAutolinkHeadings, {
content: fromHtml('<span class="header-anchor-container icon pl-3"><i class="header-anchor fas fa-lg fa-link has-text-link is-size-5"></i></span>'),
behavior: "append"
}]]

It would also be a good time to add an "Edit on GitHub" link at the bottom like on the other pages, that shouldn't be too complicated to add to the template (it inherits from Default instead of Page). Here is how it is done:

const githubUrl = SiteConfig.fileEditBaseUrl + Astro.props.frontmatter.file.replace(cwd(), "")

<p class="subtitle is-italic is-6 has-text-weight-medium is-family-primary mt-5">
<span class="icon-text">
<span class="icon">
<i class="fas fa-pencil"></i>
</span>
<span>
<a href={githubUrl} style="color: inherit">{t("edit-on-github")}</a>
</span>
</span>
</p>

@ix0rai
Copy link
Member Author

ix0rai commented Sep 18, 2023

thank you for the insight! I'm not sure "edit on github" buttons are a great fit for the blog since they're not meant to be dynamic pages, they're kinda supposed to be posted once and left unchanged unless they need corrections

@Akarys42
Copy link
Contributor

I feel like that might be useful for typos and such but yeah fair.

@Southpaw1496
Copy link
Contributor

Southpaw1496 commented Sep 18, 2023

It would also be a good time to add an "Edit on GitHub" link at the bottom like on the other pages

I feel like these sorts of buttons are best for documentation sites where there's an emphasis on community contributions and additions for the site. While we obviously appreciate community contributions, I don't think that they're really a focus for the site to the point where we need a button (with the possible exception of translations, but we don't have a proper system for that yet).

Additionally, while my experience with GitHub's editor is limited, I don't think it's up for the job of handling many of the more complex pages, and the changes it makes when it doesn't know what it's doing (not respecting indentation in many cases) will just make pull requests harder to review and correct.

@Southpaw1496
Copy link
Contributor

I have made a little progress on this. I discovered that, even Markdown headers in Astro have an id added to them, you still need the Rehype slug plugin to do it in order for the auto link plugin to work. This may be because rehype plugins are run before Astro adds the header IDs.

The only problem is I can't work out how to make the icons it generates actually visible. As far as I can tell, it runs after astro-icon in the build process, so we can't use it. You seem to control what it puts for the links by using some sort of HTML abstract syntax tree called HAST. By default it uses CSS classes that you can theoretically customise, but I still don't understand how the CSS works on this site.

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

No branches or pull requests

3 participants