Skip to content

Commit

Permalink
fix(rss): Make sure all links are absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Mar 18, 2024
1 parent 3587392 commit 3c63ef4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/layouts/ArticleLayout.astro
Expand Up @@ -38,7 +38,10 @@ const { Content, headings } = await article.render();
document.addEventListener(
"scroll",
() => {
if (window.scrollY > 350 && window.scrollY < document.body.scrollHeight - 1000) {
if (
window.scrollY > 350 &&
window.scrollY + window.innerHeight < document.body.scrollHeight - 250
) {
asides.forEach((aside, i) => {
aside.classList.toggle(i === 0 ? "opacity-35" : "opacity-65", true);
});
Expand Down
6 changes: 3 additions & 3 deletions src/middleware.ts
Expand Up @@ -26,13 +26,13 @@ export const onRequest = defineMiddleware(async (ctx, next) => {

node.name = "img";
node.attributes = attributes;
node.attributes.src = getBaseSiteURL().slice(0, -1) + node.attributes.src;
node.attributes.src = getBaseSiteURL().slice(0, -1) + src;
}
}

// Make sure links are absolute, some readers are not smart enough to figure it out
if (node.name === "a" && node.attributes.src?.startsWith("/")) {
node.attributes.src = getBaseSiteURL().slice(0, -1) + node.attributes.src;
if (node.name === "a" && node.attributes.href?.startsWith("/")) {
node.attributes.href = getBaseSiteURL().slice(0, -1) + node.attributes.href;
}

// Remove favicon images, some readers don't know they should be inline and it ends up being a broken image
Expand Down

0 comments on commit 3c63ef4

Please sign in to comment.