Personal Site
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a header to the RSS page

good god if the experimental astro container api ever deprecates im cooked lmfao

vielle.dev d028a1f8 a635f421

verified
+131 -2
+1
src/components/Header.astro
··· 66 66 </header> 67 67 68 68 <style> 69 + /* UPDATE RSS STYLE XML WHEN YOU CHANGE THESE */ 69 70 header { 70 71 border-image: var(--box-blr-png) 10 fill / 20px / 20px round; 71 72 margin: 0 20px 20px;
+130 -2
src/pages/rss.style.xml.ts
··· 1 1 import BoxTlbr from "/assets/box-tlbr.png"; 2 - import Hr from "/assets/hr.png"; 3 2 import Box4x3Mask from "/assets/box-4x3-mask.png"; 3 + import { experimental_AstroContainer } from "astro/container"; 4 + import Header from "/components/Header.astro"; 5 + 6 + const header = await experimental_AstroContainer 7 + .create() 8 + .then((x) => x.renderToString(Header)) 9 + .then((x) => 10 + // match data-astro-cid attributes where there no value 11 + // this is because xml hates boolean attributes for some reason. :( 12 + x.replaceAll(/data-astro-cid-[a-zA-Z0-9]*(?!=["'])/gm, (m) => m + '=""'), 13 + ) 14 + .then((x) => 15 + // match wbr tags (with data astro cid) and close em 16 + x.replaceAll(/<wbr data-astro-cid-[a-zA-Z0-9]*="">/gm, (m) => m + "</wbr>"), 17 + ); 4 18 5 19 export async function GET() { 6 20 return new Response( 7 21 ` 22 + <!DOCTYPE XSL [ <!ENTITY shy "­"> ]> 8 23 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 9 24 <xsl:output method="html" /> 10 25 ··· 26 41 27 42 html, 28 43 body { 44 + min-width: 30ch; 45 + } 46 + 47 + .blog { 29 48 width: 30ch; 30 49 margin: auto; 50 + } 51 + 52 + .intro { 53 + max-width: 60ch; 54 + padding-inline: 20px; 55 + margin: 20px auto; 31 56 } 32 57 33 58 img, ··· 66 91 a:active { 67 92 text-decoration-style: dashed; 68 93 } 94 + 95 + /* from Header.astro */ 96 + header { 97 + border-image: var(--box-blr-png) 10 fill / 20px / 20px round; 98 + margin: 0 20px 20px; 99 + padding: 10px 20px; 100 + height: 3rem; /* 2rem * 1.5 */ 101 + /* render over feed bg */ 102 + z-index: 2; 103 + 104 + display: flex; 105 + flex-direction: row; 106 + justify-content: space-between; 107 + align-items: center; 108 + 109 + @media (max-width: 650px) { 110 + flex-direction: column; 111 + align-items: start; 112 + height: 4.5rem; /* (2rem + 1rem) * 1.5 */ 113 + 114 + nav { 115 + margin-inline: auto; 116 + contain: inline-size; 117 + width: 100%; 118 + overflow: auto; 119 + scrollbar-width: thin; 120 + } 121 + 122 + h1 { 123 + width: 100%; 124 + text-align: center; 125 + } 126 + } 127 + 128 + &amp; > nav > ul { 129 + display: flex; 130 + flex-direction: row; 131 + align-items: center; 132 + justify-content: start; 133 + gap: 10px; 134 + z-index: 999; 135 + width: fit-content; 136 + margin-inline: auto; 137 + 138 + &amp; > li { 139 + display: flex; 140 + flex-direction: row; 141 + align-items: center; 142 + gap: 10px; 143 + 144 + &amp;::marker { 145 + content: none; 146 + } 147 + 148 + &amp; + &amp;::before { 149 + content: ""; 150 + background-image: var(--dot-png); 151 + background-size: contain; 152 + width: 9px; 153 + height: 9px; 154 + display: block; 155 + } 156 + } 157 + } 158 + } 159 + 160 + nav > ul > li:last-child > details > ul { 161 + right: 10px; 162 + } 163 + 164 + details { 165 + summary { 166 + cursor: pointer; 167 + text-wrap: nowrap; 168 + } 169 + 170 + &amp; > ul { 171 + position: absolute; 172 + z-index: 99999; 173 + 174 + @media (max-width: 650px) { 175 + inset: auto 15px; 176 + } 177 + 178 + margin-top: 10px; 179 + padding: 20px; 180 + padding-left: 40px; 181 + &amp; ul { 182 + margin-left: 10px; 183 + } 184 + 185 + border-image: var(--box-tlbr-png) 10 fill / 20px round; 186 + } 187 + } 188 + 189 + header h1 { 190 + margin-block: 0; 191 + position: sticky; 192 + inset: 0; 193 + } 69 194 </style> 70 195 </head> 71 196 72 197 <body> 73 - <section class="blog"> 198 + ${header} 199 + <section class="intro"> 74 200 <h1>Blog Posts</h1> 75 201 <p>If you want to use this page in your RSS reader, simply paste this page's URL in and it'll just work. To view the original RSS, view the page source. The styling of this page is made possible by <a href="https://developer.mozilla.org/en-US/docs/Web/XML/XSLT" target="_blank">XSLT</a></p> 202 + </section> 203 + <section class="blog"> 76 204 <xsl:for-each select="/rss/channel/item"> 77 205 <a target="_blank"> 78 206 <xsl:attribute name="href">