<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Andrei Valentin Popa</title>
    <description>The latest articles on DEV Community by Andrei Valentin Popa (@f24816).</description>
    <link>https://dev.to/f24816</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1071545%2Fefed4eb6-4da8-42f2-a9fe-8b475780be87.jpg</url>
      <title>DEV Community: Andrei Valentin Popa</title>
      <link>https://dev.to/f24816</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/f24816"/>
    <language>en</language>
    <item>
      <title>Offsetting anchors to adjust for a fixed header.</title>
      <dc:creator>Andrei Valentin Popa</dc:creator>
      <pubDate>Fri, 18 Aug 2023 17:33:07 +0000</pubDate>
      <link>https://dev.to/f24816/offsetting-anchors-to-adjust-for-a-fixed-header-in-astro-4pm5</link>
      <guid>https://dev.to/f24816/offsetting-anchors-to-adjust-for-a-fixed-header-in-astro-4pm5</guid>
      <description>&lt;p&gt;So, you got your nice little &lt;code&gt;sticky&lt;/code&gt; header, it looks good but any &lt;code&gt;#to-my-title&lt;/code&gt; or &lt;code&gt;#to-my-reference&lt;/code&gt; bits are linking to areas that are covered by the header.&lt;/p&gt;

&lt;p&gt;This is a common problem that is a bit difficult to solve but here is how I did it in my Astro project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Offsetting anchor to adjust for fixed header */&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;aria-describedby&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"footnote-label"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nd"&gt;:target&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;padding-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;h4&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;h5&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;h6&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-75px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;75px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code might look complicated, that's because it is. &lt;/p&gt;

&lt;p&gt;The first rule applies to any link (a) that has an attribute &lt;code&gt;aria-described by&lt;/code&gt; with the value footnote-label and is the target of the current URL (meaning it has a hash fragment that matches its id). This rule adds a 50% padding-top to the link, which means it will place it in the middle of the screen.&lt;/p&gt;

&lt;p&gt;The second rule applies to any heading that has an id attribute. This rule adds a pseudo-element (:before) to the heading, which is an invisible element that is inserted before the heading’s content. This pseudo-element has a height of 75px and a negative margin-top of 75px, which means it will occupy the same space as the heading but will not affect its position or layout, placing the "target" of the link actually a little bit above the actual heading.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to add hard breaks to your Astro Blog</title>
      <dc:creator>Andrei Valentin Popa</dc:creator>
      <pubDate>Fri, 18 Aug 2023 15:12:07 +0000</pubDate>
      <link>https://dev.to/f24816/how-to-add-hard-breaks-to-your-astro-blog-1gpn</link>
      <guid>https://dev.to/f24816/how-to-add-hard-breaks-to-your-astro-blog-1gpn</guid>
      <description>&lt;p&gt;In my opinion, soft breaks are absolutely useless, would you write your content in markdown and not add space between paragraphs?&lt;/p&gt;

&lt;p&gt;Besides that some content has to be displayed with hard breaks and it's annoying to add a &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; or other escape character.&lt;/p&gt;

&lt;p&gt;Astro uses &lt;code&gt;remark&lt;/code&gt; to render markdown so if you want to add hard breaks you have to install the &lt;code&gt;remark-breaks&lt;/code&gt; plugin.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;remark-breaks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then modify &lt;code&gt;astro.config.mjs&lt;/code&gt; and enable the plugin.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;remarkBreaks&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;remark-breaks&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;markdown&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;remarkPlugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;remarkBreaks&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
