Skip to content

Commit

Permalink
Merge pull request #428 from 18F/eoc/274
Browse files Browse the repository at this point in the history
Manually add heading links to headers in partials
  • Loading branch information
echappen authored Dec 29, 2023
2 parents bf1705f + 6550ba9 commit 4a7ba46
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions _includes/heading-link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% comment %}
Use this partial when headings links aren't generated through markdown.
Add this partial within the heading you want to link.
Heading id must be the same as the slug passed to this partial.
{% endcomment %}
<span aria-hidden="true">
<a href="#{{ slug }}"
class="heading-permalink"
aria-label="permanent link to {{ slug }} heading">
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
<use xlink:href="#svg-link"></use>
</svg>
</a>
</span>
6 changes: 4 additions & 2 deletions _includes/methods/method.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ <h1 class="method--title" itemprop="headline"><a href="{{ method_path | url }}">
{{ this_method.title }}
{% endif %}
</a></h1>
<h2>What</h2>
{% capture what_heading_slug %}what-{{ this_method.title | slugify }}{% endcapture %}
<h2 id="{{ what_heading_slug }}">What {% include "heading-link.html", slug: what_heading_slug %}</h2>
<p>{{ this_method.what }}</p>
<h2>Why</h2>
{% capture why_heading_slug %}why-{{ this_method.title | slugify }}{% endcapture %}
<h2 id="{{ why_heading_slug }}">Why {% include "heading-link.html", slug: why_heading_slug %}</h2>
<p>{{ this_method.why }}</p>
<footer>
<section class="method--section method--section--category">
Expand Down
6 changes: 6 additions & 0 deletions assets/methods/styles/_method.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
font-weight: font-weight('bold');
}

/* custom header link icon color */
.method h2 span a,
.method h2 span a:visited {
color: $color-body-dark;
}

.method--panel {
display: block;
padding: units(2.5) units(5);
Expand Down

0 comments on commit 4a7ba46

Please sign in to comment.