Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove uneeded image regex #29

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/pages/news/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ const article = await fetchArticleById({
api_url: import.meta.env.API_URL,
});

// Function to replace <embed> tags with <img> tags for images
const processEmbedTags = (html: string) => {
return html.replace(
/<img([^>]+)alt="([^"]+)"([^>]+)src="([^"]+)"([^>]*)>/g,
(match, pre, alt, mid, src, post) => {
const absoluteSrc = new URL(src, import.meta.env.API_URL);
return `<img ${pre} src="${absoluteSrc.toString()}" ${mid} alt="${alt}" ${post}/>`;
},
);
};

// Process embed tags to replace them with <img> tags
const finishedHtml = processEmbedTags(article.body);
---

<Layout title=`The Gathering - ${article.title}`>
Expand Down Expand Up @@ -87,6 +74,6 @@ const finishedHtml = processEmbedTags(article.body);
)
}
<!-- Article Content -->
<div class="prose" set:html={finishedHtml} />
<div class="prose" set:html={article.body} />
</Main>
</Layout>