Skip to content

Commit

Permalink
Restore code body if val.town request fails
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph committed Oct 7, 2024
1 parent 67d8dd8 commit 619bba5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/astro-md/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class SyntaxHighlightRewriter implements HTMLRewriterElementContentHandlers {
},
}
);
if (!res.ok) {
// Something went wrong with the request, just return the original code
text.replace(`<code>${this.code}</code>`, { html: true });
return;
}
const data = await res.text();
this.runtime.ctx.waitUntil(this.cache.put(key, data));
text.replace(data, { html: true });
Expand Down

0 comments on commit 619bba5

Please sign in to comment.