Skip to content

Commit 0aba521

Browse files
committedOct 5, 2020
Make heading anchors more generic
1 parent a075f1d commit 0aba521

File tree

4 files changed

+40
-33
lines changed

4 files changed

+40
-33
lines changed
 

‎_macros/blog-post.html.twig

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
<p class="c-blog-post__date">{{ post.date | date('M d, Y') }}</p>
1010
</header>
1111

12-
<section class="c-blog-post__body">
12+
<section class="c-blog-post__body s-markdown">
1313
{% if summary %}
1414
{{ post.content | summary }}
1515
{% else %}
1616
{{ post.content | anchors(
1717
anchorBody='<span class="sr-only">Permalink to "{heading}" section</span>',
18-
anchorClass='c-blog-post__body__anchor'
18+
anchorClass='c-heading-anchor'
1919
) }}
2020
{% endif %}
2121
</section>

‎_pages/about.html.twig

+9-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ description: I'm just another boring developer pretending to know what he's doin
8484
{% endmacro %}
8585

8686
{% block content %}
87-
{% markdown %}
87+
{% set page_content %}{% markdown %}
8888
*[CMS]: Content Management System
8989

9090
# About
@@ -152,5 +152,12 @@ description: I'm just another boring developer pretending to know what he's doin
152152
content: 'content',
153153
}
154154
) }}
155-
{% endmarkdown %}
155+
{% endmarkdown %}{% endset %}
156+
157+
<div class="s-markdown">
158+
{{ page_content | anchors(
159+
anchorBody='<span class="sr-only">Permalink to "{heading}" section</span>',
160+
anchorClass='c-heading-anchor'
161+
) }}
162+
</div>
156163
{% endblock %}

‎_sass/components/_blog-post.scss

-29
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,6 @@
4242
}
4343

4444
.c-blog-post__body {
45-
h1, h2, h3,
46-
h4, h5, h6 {
47-
align-items: center;
48-
display: flex;
49-
width: 100%;
50-
51-
.c-blog-post__body__anchor {
52-
@include margin(l, 2);
53-
54-
opacity: 0;
55-
font-size: 0.75em;
56-
text-decoration: none;
57-
58-
&::after {
59-
content: '\00B6';
60-
}
61-
62-
&:focus {
63-
opacity: 1;
64-
}
65-
}
66-
67-
&:hover {
68-
.c-blog-post__body__anchor {
69-
opacity: 1;
70-
}
71-
}
72-
}
73-
7445
ul {
7546
@include padding(l, 4);
7647
}

‎_sass/layout/_markdown.scss

+29
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,35 @@
33
text-decoration: underline;
44
}
55

6+
h1, h2, h3,
7+
h4, h5, h6 {
8+
align-items: center;
9+
display: flex;
10+
width: 100%;
11+
12+
.c-heading-anchor {
13+
@include margin(l, 2);
14+
15+
opacity: 0;
16+
font-size: 0.75em;
17+
text-decoration: none;
18+
19+
&::after {
20+
content: '\00B6';
21+
}
22+
23+
&:focus {
24+
opacity: 1;
25+
}
26+
}
27+
28+
&:hover {
29+
.c-heading-anchor {
30+
opacity: 1;
31+
}
32+
}
33+
}
34+
635
*:last-child {
736
margin-bottom: 0;
837
}

0 commit comments

Comments
 (0)
Please sign in to comment.