diff --git a/_includes/layouts/base.njk b/_includes/layouts/base.njk index a3a43f9..36bc073 100644 --- a/_includes/layouts/base.njk +++ b/_includes/layouts/base.njk @@ -22,42 +22,61 @@ 4. Learn more: https://github.com/11ty/eleventy-plugin-bundle #} + {#- Add the contents of a file to the bundle #} + {%- css %}{% include "public/css/index.css" %}{% endcss %} + + {%- if not metadata.mono %} + {%- css %}{% include "public/css/rainbow.css" %}{% endcss %} + {% endif %} + {#- Or add from node_modules #} + {# {%- css %}{% include "node_modules/prismjs/themes/prism-okaidia.css" %}{% endcss %} #} + {#- Add an arbitrary string to the bundle #} {%- css %} -* { box-sizing: border-box; } +:root { + --anchored-heading-gap: 0.375; + --anchored-heading-margin: calc(var(--anchored-heading-gap) * 1ch); + --anchored-heading-rem: calc(var(--anchored-heading-gap) * 1rem); + --anchored-heading-min-size: 1.328125rem; {# calc(var(--article-font-size) * var(--article-h4-size)) #} + --anchored-heading-difference: calc(var(--anchored-heading-gap) * var(--anchored-heading-min-size) - var(--anchored-heading-rem)); + --anchored-heading-offset: calc(var(--anchored-heading-min-size) + var(--anchored-heading-difference)); +} + +.anchored-heading { + align-items: last baseline; + display: flex; + margin-block-end: 1.5rem; + margin-block-start: 1.5rem; +} -heading-anchors a[href^="#"] { +.anchored-heading :is(h1, h2, h3, h4) { + margin-block-end: 0; + margin-block-start: 0; + max-inline-size: calc(100% - var(--anchored-heading-offset)); +} + +heading-anchors a[href].direct-link { color: transparent; - display: inline-block; - margin-inline-start: 0.375ch; + margin-inline-start: var(--anchored-heading-margin); max-inline-size: 1ch; overflow-x: hidden; pointer-events: none; text-decoration: none; - vertical-align: bottom; white-space: nowrap; } -heading-anchors a[href^="#"]::before { - content: "#"; +heading-anchors a[href].direct-link::before { color: var(--text-color-link); + content: "#"; pointer-events: auto; } -heading-anchors a[href^="#"]:focus::before, -heading-anchors a[href^="#"]:hover::before { +heading-anchors a[href].direct-link:focus::before, +heading-anchors a[href].direct-link:hover::before { color: var(--text-color-link-highlight); text-decoration: underline; } {% endcss %} - {#- Add the contents of a file to the bundle #} - {%- css %}{% include "public/css/index.css" %}{% endcss %} - - {%- if not metadata.mono %} - {%- css %}{% include "public/css/rainbow.css" %}{% endcss %} - {% endif %} - {#- Or add from node_modules #} - {# {%- css %}{% include "node_modules/prismjs/themes/prism-okaidia.css" %}{% endcss %} #} {#- Render the CSS bundle using Inlined CSS (for the fastest site performance in production) #} @@ -86,7 +105,7 @@ heading-anchors a[href^="#"]:hover::before {
- + {{ content | safe }}
diff --git a/_includes/layouts/post.njk b/_includes/layouts/post.njk index 337d24b..4d591a9 100644 --- a/_includes/layouts/post.njk +++ b/_includes/layouts/post.njk @@ -2,11 +2,20 @@ layout: layouts/base.njk --- {%- css %} -/* Only include the syntax highlighter CSS on blog posts */ +{# Only include the syntax highlighter CSS on blog posts #} {% include "node_modules/prismjs/themes/prism-okaidia.css" %} {% include "public/css/prism-diff.css" %} +pre[class*="language-"] { + margin: .375rem 0 1.5rem; +} + +{# no top margin on post hero or title #} +main figure.hero:first-of-type, +main h1.title:first-of-type { + margin-block-start: 0; +} {%- endcss %} -
+
{%- if hero and heroalt %} {%- if herolink %} @@ -28,7 +37,7 @@ layout: layouts/base.njk {%- endif %} {%- endif %}
-

{{ title }}

+

{{ title }}