From a2d2385d3f0cb073844fb1ba3e42729ba16d44ae Mon Sep 17 00:00:00 2001 From: Jonas-Merlin Schumacher Date: Thu, 23 Mar 2023 11:09:34 +0100 Subject: [PATCH] feat: add option to surpress warnings --- src/SEO.astro | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/SEO.astro b/src/SEO.astro index 36ced73..b637fa2 100644 --- a/src/SEO.astro +++ b/src/SEO.astro @@ -76,6 +76,7 @@ export interface Props { link?: Partial[]; meta?: Partial[]; }; + surpressWarnings?: boolean; } const { props } = Astro; @@ -88,6 +89,7 @@ const { noindex, nofollow, charset, + surpressWarnings, } = props; function validateProps(props) { @@ -108,16 +110,20 @@ function validateProps(props) { if (title && openGraph?.basic.title) { if (title == openGraph.basic.title) { - console.warn( - "WARNING(astro-seo): You passed the same value to `title` and `openGraph.optional.title`. This is most likely not what you want. See docs for more." - ); + if (!surpressWarnings) { + console.warn( + "WARNING(astro-seo): You passed the same value to `title` and `openGraph.optional.title`. This is most likely not what you want. See docs for more." + ); + } } } if (openGraph?.basic?.image && !openGraph?.image?.alt) { - console.warn( - "WARNING(astro-seo): You defined `openGraph.basic.image`, but didn't define `openGraph.image.alt`. This is stongly discouraged.'" - ); + if (!surpressWarnings) { + console.warn( + "WARNING(astro-seo): You defined `openGraph.basic.image`, but didn't define `openGraph.image.alt`. This is stongly discouraged.'" + ); + } } }