Skip to content

Commit

Permalink
update meta desc
Browse files Browse the repository at this point in the history
  • Loading branch information
joevaugh4n committed Dec 17, 2024
1 parent 57489b0 commit 3ae235e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/layouts/Post.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
import Layout, { OGType } from "./Layout.astro";
import ContactForm from "../components/Contact.astro";
import HR from "../components/atoms/HR.astro";
import { decode } from "html-entities";
function sanitizeMetadata(input: string): string {
const noHtml = input.replace(/<\/?[^>]+(>|$)/g, ""); // Remove HTML tags
const decoded = decode(noHtml); // Decode HTML entities
return decoded.trim().replace(/\n/g, ""); // Remove newlines and trim
}
interface Props {
title: string;
Expand All @@ -10,11 +17,15 @@ interface Props {
}
const { title, description, ogImage } = Astro.props;
const sanitizedText = sanitizeMetadata(description);
console.log(sanitizedText);
---

<Layout
title={title}
metaDescription={description}
metaDescription={sanitizedText}
ogType={OGType.Article}
ogImage={ogImage}
>
Expand Down

0 comments on commit 3ae235e

Please sign in to comment.