From b53cac724836942c08cfcb355f358af28e8fefc5 Mon Sep 17 00:00:00 2001 From: Dawid Pers Date: Wed, 14 Jan 2026 15:09:38 +0100 Subject: [PATCH 1/5] add whitelisted domains for content links --- package.json | 2 +- .../StoryContentBlocks/ParagraphBlock.astro | 2 + src/configs/SEOWebsitesConfig.ts | 38 +++++++- src/helpers/ConfigHelper.ts | 5 + src/helpers/SeoLinkHelper.ts | 92 +++++++++++++++++++ 5 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 src/helpers/SeoLinkHelper.ts diff --git a/package.json b/package.json index f991a406..a5494495 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hat-ring-components", - "version": "4.4.3", + "version": "4.5.0", "description": "Head App Template - RING components", "license": "MIT", "repository": {}, diff --git a/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro b/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro index 3281fea4..1acc8789 100644 --- a/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro +++ b/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro @@ -2,6 +2,7 @@ const { context, blockData }: ParagraphBlockParams = Astro.props as ParagraphBlockParams; import { WidgetHelper_renderEmptyComponent } from "../../../../../helpers/WidgetHelper"; import {LinkReplacerHelper_replaceLinks} from '../../../../../helpers/LinkReplacerHelper'; +import { SeoLinkHelper_processLinks } from "../../../../../helpers/SeoLinkHelper"; import { AppContext } from "../../../../../types/types"; export interface ParagraphBlockParams { @@ -17,6 +18,7 @@ if (!blockData) { } blockData.text = await LinkReplacerHelper_replaceLinks(context, blockData.text); +blockData.text = await SeoLinkHelper_processLinks(context, blockData.text); --- { diff --git a/src/configs/SEOWebsitesConfig.ts b/src/configs/SEOWebsitesConfig.ts index 86a1c244..03bb42a8 100644 --- a/src/configs/SEOWebsitesConfig.ts +++ b/src/configs/SEOWebsitesConfig.ts @@ -68,6 +68,14 @@ export let SEOWebsitesConfig "fields": [ "metaData.customMetaTags" ] + }, + "contentLinks": { + "type": "group", + "name": "Content Link Settings", + "fields": [ + "contentLinks.enableDomainWhitelist", + "contentLinks.whitelistedDomains" + ] } }, "keys": [ @@ -76,7 +84,8 @@ export let SEOWebsitesConfig "seoLanguages", "rssDefault", "seoOpenGraph", - "metaData" + "metaData", + "contentLinks" ] } ], @@ -121,6 +130,10 @@ export let SEOWebsitesConfig }, "metaData": { "customMetaTags": [] + }, + "contentLinks": { + "enableDomainWhitelist": false, + "whitelistedDomains": [] } }, "paramsDescription": { @@ -338,6 +351,29 @@ export let SEOWebsitesConfig } ] } + }, + "contentLinks": { + "enableDomainWhitelist": { + "name": "Enable domain whitelist for content links", + "type": "checkbox" + }, + "whitelistedDomains": { + "type": "treeobject", + "name": "Whitelisted domains", + "description": "List of whitelisted domains. All links from content outside this list will have 'noindex nofollow'.", + "properties": [ + { + "name": "domain", + "description": "Domain name (e.g., example.com, example.xy.com)", + "type": "textfield" + }, + { + "name": "rel Attribute", + "description": "rel attribute value for this domain (leave empty for default)", + "type": "textfield" + } + ] + } } } } diff --git a/src/helpers/ConfigHelper.ts b/src/helpers/ConfigHelper.ts index 632e16b1..365d9eb7 100644 --- a/src/helpers/ConfigHelper.ts +++ b/src/helpers/ConfigHelper.ts @@ -223,3 +223,8 @@ export async function ConfigHelper_getMainCategoryUuid(context) { const developerSettings = await ConfigHelper_getDeveloperSettingsConfig(context); return developerSettings ? developerSettings.mainCategoryUuid : ''; } + +export async function ConfigHelper_getContentLinksConfig(context) { + return ConfigHelper_getConfig(context, 'contentLinks'); +} + diff --git a/src/helpers/SeoLinkHelper.ts b/src/helpers/SeoLinkHelper.ts new file mode 100644 index 00000000..a9575ceb --- /dev/null +++ b/src/helpers/SeoLinkHelper.ts @@ -0,0 +1,92 @@ +import { AppContext } from "../types/types"; +import { ConfigHelper_getContentLinksConfig } from "./ConfigHelper"; + +export async function SeoLinkHelper_processLinks(context: AppContext, text: string): Promise { + if (!text) { + return text; + } + + try { + const contentLinksConfig = await ConfigHelper_getContentLinksConfig(context); + + if (!contentLinksConfig?.enableDomainWhitelist) { + return text; + } + + const whitelistedDomainsList = contentLinksConfig.whitelistedDomains; + + if (!whitelistedDomainsList?.length) { + return text; + } + + const whitelistedDomains = whitelistedDomainsList + .filter((item) => item.domain && item.domain.trim()) + .map((item) => { + return { ...item, domain: item.domain.trim().toLowerCase() }; + }); + + return text.replace(/]*?href=["'](https?:\/\/[^"']+)["'][^>]*?>/gi, (matchedLink, href) => { + try { + let domain = ""; + try { + const url = new URL(href); + domain = url.hostname.toLowerCase(); + } catch (e) { + console.error(`SeoLinkHelper: Failed to parse URL "${href}"`, e); + return matchedLink; + } + + const matchWithWhitelist = whitelistedDomains.find((item) => { + return domain === item.domain || domain.endsWith("." + item.domain); + }); + + const relRegex = /\s+rel=["']([^"']*)["']/i; + const existingRelMatch = matchedLink.match(relRegex); + let currentRelAttributes = + existingRelMatch && existingRelMatch[1] + ? existingRelMatch[1].split(/\s+/).map((r) => r.trim()) + : []; + + if (matchWithWhitelist) { + currentRelAttributes = currentRelAttributes.filter( + (attr) => attr !== "nofollow" && attr !== "noindex" + ); + + if (matchWithWhitelist.relAttribute) { + const configRelAttributes = matchWithWhitelist.relAttribute.toLowerCase().split(/\s+/); + configRelAttributes.forEach((r) => { + if (r && !currentRelAttributes.includes(r)) { + currentRelAttributes.push(r); + } + }); + } + } else { + if (!currentRelAttributes.includes("nofollow")) { + currentRelAttributes.push("nofollow"); + } + if (!currentRelAttributes.includes("noindex")) { + currentRelAttributes.push("noindex"); + } + } + + const newRelString = currentRelAttributes.length > 0 ? ` rel="${currentRelAttributes.join(" ")}"` : ""; + + if (existingRelMatch) { + return matchedLink.replace(relRegex, newRelString); + } else { + if (newRelString) { + return matchedLink.substring(0, matchedLink.length - 1) + newRelString + ">"; + } + } + + return matchedLink; + } catch (innerError) { + console.error("SeoLinkHelper: Error processing individual link match", innerError); + return matchedLink; + } + }); + } catch (error) { + console.error("SeoLinkHelper: Global error processing links", error); + return text; + } +} From d7aebb31ef37e1eef75c41f23a5b34755db8e701 Mon Sep 17 00:00:00 2001 From: Dawid Pers Date: Wed, 14 Jan 2026 15:36:52 +0100 Subject: [PATCH 2/5] fix --- src/configs/SEOWebsitesConfig.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/configs/SEOWebsitesConfig.ts b/src/configs/SEOWebsitesConfig.ts index 03bb42a8..0b6f59c2 100644 --- a/src/configs/SEOWebsitesConfig.ts +++ b/src/configs/SEOWebsitesConfig.ts @@ -368,8 +368,8 @@ export let SEOWebsitesConfig "type": "textfield" }, { - "name": "rel Attribute", - "description": "rel attribute value for this domain (leave empty for default)", + "name": "Rel attribute", + "description": "Rel attribute value for this domain (leave empty for default), e.g., noreferrer, noopener", "type": "textfield" } ] From 7c5d5b55a060b93e6d7ab46b739ee8ddd0ec3fc1 Mon Sep 17 00:00:00 2001 From: Dawid Pers Date: Wed, 14 Jan 2026 16:06:28 +0100 Subject: [PATCH 3/5] fix --- .../StoryContent/StoryContentBlocks/ParagraphBlock.astro | 2 +- src/configs/SEOWebsitesConfig.ts | 8 ++++---- src/helpers/{ => seo}/SeoLinkHelper.ts | 9 +++------ 3 files changed, 8 insertions(+), 11 deletions(-) rename src/helpers/{ => seo}/SeoLinkHelper.ts (90%) diff --git a/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro b/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro index 1acc8789..7419dd1e 100644 --- a/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro +++ b/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro @@ -2,7 +2,7 @@ const { context, blockData }: ParagraphBlockParams = Astro.props as ParagraphBlockParams; import { WidgetHelper_renderEmptyComponent } from "../../../../../helpers/WidgetHelper"; import {LinkReplacerHelper_replaceLinks} from '../../../../../helpers/LinkReplacerHelper'; -import { SeoLinkHelper_processLinks } from "../../../../../helpers/SeoLinkHelper"; +import { SeoLinkHelper_processLinks } from "../../../../../helpers/seo/SeoLinkHelper"; import { AppContext } from "../../../../../types/types"; export interface ParagraphBlockParams { diff --git a/src/configs/SEOWebsitesConfig.ts b/src/configs/SEOWebsitesConfig.ts index 0b6f59c2..cd0a40f7 100644 --- a/src/configs/SEOWebsitesConfig.ts +++ b/src/configs/SEOWebsitesConfig.ts @@ -132,8 +132,8 @@ export let SEOWebsitesConfig "customMetaTags": [] }, "contentLinks": { - "enableDomainWhitelist": false, - "whitelistedDomains": [] + "enableDomainWhitelist": false, + "whitelistedDomains": [] } }, "paramsDescription": { @@ -360,7 +360,7 @@ export let SEOWebsitesConfig "whitelistedDomains": { "type": "treeobject", "name": "Whitelisted domains", - "description": "List of whitelisted domains. All links from content outside this list will have 'noindex nofollow'.", + "description": "List of whitelisted domains. All links from content outside this list will have 'nofollow'.", "properties": [ { "name": "domain", @@ -368,7 +368,7 @@ export let SEOWebsitesConfig "type": "textfield" }, { - "name": "Rel attribute", + "name": "relAttribute", "description": "Rel attribute value for this domain (leave empty for default), e.g., noreferrer, noopener", "type": "textfield" } diff --git a/src/helpers/SeoLinkHelper.ts b/src/helpers/seo/SeoLinkHelper.ts similarity index 90% rename from src/helpers/SeoLinkHelper.ts rename to src/helpers/seo/SeoLinkHelper.ts index a9575ceb..dec71e8e 100644 --- a/src/helpers/SeoLinkHelper.ts +++ b/src/helpers/seo/SeoLinkHelper.ts @@ -1,5 +1,5 @@ -import { AppContext } from "../types/types"; -import { ConfigHelper_getContentLinksConfig } from "./ConfigHelper"; +import { AppContext } from "../../types/types"; +import { ConfigHelper_getContentLinksConfig } from "../ConfigHelper"; export async function SeoLinkHelper_processLinks(context: AppContext, text: string): Promise { if (!text) { @@ -49,7 +49,7 @@ export async function SeoLinkHelper_processLinks(context: AppContext, text: stri if (matchWithWhitelist) { currentRelAttributes = currentRelAttributes.filter( - (attr) => attr !== "nofollow" && attr !== "noindex" + (attr) => attr !== "nofollow" ); if (matchWithWhitelist.relAttribute) { @@ -64,9 +64,6 @@ export async function SeoLinkHelper_processLinks(context: AppContext, text: stri if (!currentRelAttributes.includes("nofollow")) { currentRelAttributes.push("nofollow"); } - if (!currentRelAttributes.includes("noindex")) { - currentRelAttributes.push("noindex"); - } } const newRelString = currentRelAttributes.length > 0 ? ` rel="${currentRelAttributes.join(" ")}"` : ""; From 8c7c41686404abfb5453d9a71e06896bc7564a75 Mon Sep 17 00:00:00 2001 From: Dawid Pers Date: Wed, 28 Jan 2026 14:07:19 +0100 Subject: [PATCH 4/5] add whitelist for content links --- .../StoryContentBlocks/OrderedListBlock.astro | 8 +- .../StoryContentBlocks/ParagraphBlock.astro | 4 +- .../UnorderedListBlock.astro | 8 +- src/helpers/seo/SeoLinkHelper.ts | 89 ----------------- src/helpers/seo/SeoLinkWhitelistHelper.ts | 98 +++++++++++++++++++ 5 files changed, 110 insertions(+), 97 deletions(-) delete mode 100644 src/helpers/seo/SeoLinkHelper.ts create mode 100644 src/helpers/seo/SeoLinkWhitelistHelper.ts diff --git a/src/components/widgets/Story/StoryContent/StoryContentBlocks/OrderedListBlock.astro b/src/components/widgets/Story/StoryContent/StoryContentBlocks/OrderedListBlock.astro index 3857fc49..98dba353 100644 --- a/src/components/widgets/Story/StoryContent/StoryContentBlocks/OrderedListBlock.astro +++ b/src/components/widgets/Story/StoryContent/StoryContentBlocks/OrderedListBlock.astro @@ -3,6 +3,7 @@ const { context, blockData }: OrderedListBlockParams = Astro.props as OrderedListBlockParams; import { WidgetHelper_renderEmptyComponent } from "../../../../../helpers/WidgetHelper"; import {LinkReplacerHelper_replaceLinks} from '../../../../../helpers/LinkReplacerHelper'; +import { SeoLinkWhitelistHelper_processLinks } from "../../../../../helpers/seo/SeoLinkWhitelistHelper"; import { AppContext } from "../../../../../types/types"; export interface OrderedListBlockParams { @@ -15,13 +16,14 @@ export interface OrderedListBlockParams { startValue: number; }; } -let toRender: boolean | JSX.Element = false; -if (!blockData) { +let toRender: boolean | JSX.Element | String = false; +if (!blockData?.entries?.length) { toRender = WidgetHelper_renderEmptyComponent("OrderedListBlock"); } blockData.entries = await Promise.all(blockData.entries.map(async (entry) => { - return LinkReplacerHelper_replaceLinks(context, entry); + let processed = await LinkReplacerHelper_replaceLinks(context, entry); + return SeoLinkWhitelistHelper_processLinks(context, processed); })); --- diff --git a/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro b/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro index 7419dd1e..8be61930 100644 --- a/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro +++ b/src/components/widgets/Story/StoryContent/StoryContentBlocks/ParagraphBlock.astro @@ -2,7 +2,7 @@ const { context, blockData }: ParagraphBlockParams = Astro.props as ParagraphBlockParams; import { WidgetHelper_renderEmptyComponent } from "../../../../../helpers/WidgetHelper"; import {LinkReplacerHelper_replaceLinks} from '../../../../../helpers/LinkReplacerHelper'; -import { SeoLinkHelper_processLinks } from "../../../../../helpers/seo/SeoLinkHelper"; +import { SeoLinkWhitelistHelper_processLinks } from "../../../../../helpers/seo/SeoLinkWhitelistHelper"; import { AppContext } from "../../../../../types/types"; export interface ParagraphBlockParams { @@ -18,7 +18,7 @@ if (!blockData) { } blockData.text = await LinkReplacerHelper_replaceLinks(context, blockData.text); -blockData.text = await SeoLinkHelper_processLinks(context, blockData.text); +blockData.text = await SeoLinkWhitelistHelper_processLinks(context, blockData.text); --- { diff --git a/src/components/widgets/Story/StoryContent/StoryContentBlocks/UnorderedListBlock.astro b/src/components/widgets/Story/StoryContent/StoryContentBlocks/UnorderedListBlock.astro index 287c57c8..1a6ed882 100644 --- a/src/components/widgets/Story/StoryContent/StoryContentBlocks/UnorderedListBlock.astro +++ b/src/components/widgets/Story/StoryContent/StoryContentBlocks/UnorderedListBlock.astro @@ -3,6 +3,7 @@ const { context, blockData }: UnorderedListBlockParams = Astro.props as UnorderedListBlockParams; import { WidgetHelper_renderEmptyComponent } from "../../../../../helpers/WidgetHelper"; import {LinkReplacerHelper_replaceLinks} from '../../../../../helpers/LinkReplacerHelper'; +import { SeoLinkWhitelistHelper_processLinks } from "../../../../../helpers/seo/SeoLinkWhitelistHelper"; import { AppContext } from "../../../../../types/types"; export interface UnorderedListBlockParams { @@ -14,14 +15,15 @@ export interface UnorderedListBlockParams { styleType: string; }; } -let toRender: boolean | JSX.Element = false; +let toRender: boolean | JSX.Element | String = false; -if (!blockData) { +if (!blockData?.entries?.length) { toRender = WidgetHelper_renderEmptyComponent("UnorderedListBlock"); } blockData.entries = await Promise.all(blockData.entries.map(async (entry) => { - return LinkReplacerHelper_replaceLinks(context, entry); + let processed = await LinkReplacerHelper_replaceLinks(context, entry); + return SeoLinkWhitelistHelper_processLinks(context, processed); })); --- diff --git a/src/helpers/seo/SeoLinkHelper.ts b/src/helpers/seo/SeoLinkHelper.ts deleted file mode 100644 index dec71e8e..00000000 --- a/src/helpers/seo/SeoLinkHelper.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { AppContext } from "../../types/types"; -import { ConfigHelper_getContentLinksConfig } from "../ConfigHelper"; - -export async function SeoLinkHelper_processLinks(context: AppContext, text: string): Promise { - if (!text) { - return text; - } - - try { - const contentLinksConfig = await ConfigHelper_getContentLinksConfig(context); - - if (!contentLinksConfig?.enableDomainWhitelist) { - return text; - } - - const whitelistedDomainsList = contentLinksConfig.whitelistedDomains; - - if (!whitelistedDomainsList?.length) { - return text; - } - - const whitelistedDomains = whitelistedDomainsList - .filter((item) => item.domain && item.domain.trim()) - .map((item) => { - return { ...item, domain: item.domain.trim().toLowerCase() }; - }); - - return text.replace(/]*?href=["'](https?:\/\/[^"']+)["'][^>]*?>/gi, (matchedLink, href) => { - try { - let domain = ""; - try { - const url = new URL(href); - domain = url.hostname.toLowerCase(); - } catch (e) { - console.error(`SeoLinkHelper: Failed to parse URL "${href}"`, e); - return matchedLink; - } - - const matchWithWhitelist = whitelistedDomains.find((item) => { - return domain === item.domain || domain.endsWith("." + item.domain); - }); - - const relRegex = /\s+rel=["']([^"']*)["']/i; - const existingRelMatch = matchedLink.match(relRegex); - let currentRelAttributes = - existingRelMatch && existingRelMatch[1] - ? existingRelMatch[1].split(/\s+/).map((r) => r.trim()) - : []; - - if (matchWithWhitelist) { - currentRelAttributes = currentRelAttributes.filter( - (attr) => attr !== "nofollow" - ); - - if (matchWithWhitelist.relAttribute) { - const configRelAttributes = matchWithWhitelist.relAttribute.toLowerCase().split(/\s+/); - configRelAttributes.forEach((r) => { - if (r && !currentRelAttributes.includes(r)) { - currentRelAttributes.push(r); - } - }); - } - } else { - if (!currentRelAttributes.includes("nofollow")) { - currentRelAttributes.push("nofollow"); - } - } - - const newRelString = currentRelAttributes.length > 0 ? ` rel="${currentRelAttributes.join(" ")}"` : ""; - - if (existingRelMatch) { - return matchedLink.replace(relRegex, newRelString); - } else { - if (newRelString) { - return matchedLink.substring(0, matchedLink.length - 1) + newRelString + ">"; - } - } - - return matchedLink; - } catch (innerError) { - console.error("SeoLinkHelper: Error processing individual link match", innerError); - return matchedLink; - } - }); - } catch (error) { - console.error("SeoLinkHelper: Global error processing links", error); - return text; - } -} diff --git a/src/helpers/seo/SeoLinkWhitelistHelper.ts b/src/helpers/seo/SeoLinkWhitelistHelper.ts new file mode 100644 index 00000000..b14e33a2 --- /dev/null +++ b/src/helpers/seo/SeoLinkWhitelistHelper.ts @@ -0,0 +1,98 @@ +import { AppContext } from "../../types/types"; +import { ConfigHelper_getContentLinksConfig } from "../ConfigHelper"; + +interface WhitelistedDomain { + domain: string; + relAttribute?: string; +} + +interface ContentLinksConfig { + enableDomainWhitelist?: boolean; + whitelistedDomains?: WhitelistedDomain[]; +} + +const LINK_REGEX = /]*?href=["'](https?:\/\/[^"']+)["'][^>]*?>/gi; +const REL_REGEX = /\s+rel=["']([^"']*)["']/i; + +export async function SeoLinkWhitelistHelper_processLinks(context: AppContext, text: string): Promise { + if (!text) { + return text; + } + + try { + const contentLinksConfig = await ConfigHelper_getContentLinksConfig(context) as ContentLinksConfig; + const whitelistedDomainsList = contentLinksConfig?.whitelistedDomains; + + if (!contentLinksConfig?.enableDomainWhitelist || !whitelistedDomainsList?.length) { + return text; + } + + const whitelistedDomains = whitelistedDomainsList + .filter((item) => item.domain?.trim()) + .map((item) => ({ + ...item, + domain: item.domain.trim().toLowerCase() + })); + + if (whitelistedDomains.length === 0) { + return text; + } + + return text.replace(LINK_REGEX, (matchedLink, href) => { + let domain: string; + try { + domain = new URL(href).hostname.toLowerCase(); + } catch { + return matchedLink; + } + + const matchWithWhitelist = whitelistedDomains.find((item) => + domain === item.domain || domain.endsWith(`.${item.domain}`) + ); + + const existingRelMatch = matchedLink.match(REL_REGEX); + const currentRelAttributes = existingRelMatch?.[1] + ? existingRelMatch[1].split(/\s+/).filter(Boolean) + : []; + + if (matchWithWhitelist) { + // Remove nofollow for whitelisted domains + const filtered = currentRelAttributes.filter((attr) => attr !== "nofollow"); + + // Add configured rel attributes + if (matchWithWhitelist.relAttribute) { + const configAttrs = matchWithWhitelist.relAttribute.toLowerCase().split(/\s+/).filter(Boolean); + configAttrs.forEach((attr) => { + if (!filtered.includes(attr)) { + filtered.push(attr); + } + }); + } + currentRelAttributes.length = 0; + currentRelAttributes.push(...filtered); + } else { + // Add nofollow for non-whitelisted domains + if (!currentRelAttributes.includes("nofollow")) { + currentRelAttributes.push("nofollow"); + } + } + + const newRelString = currentRelAttributes.length > 0 + ? ` rel="${currentRelAttributes.join(" ")}"` + : ""; + + if (existingRelMatch) { + return matchedLink.replace(REL_REGEX, newRelString); + } + + if (newRelString) { + return matchedLink.slice(0, -1) + newRelString + ">"; + } + + return matchedLink; + }); + } catch (error) { + console.error("SeoLinkWhitelistHelper: Error processing links", error); + return text; + } +} From 27c42af153e4478fa0945bd670c616fd965dbe2e Mon Sep 17 00:00:00 2001 From: Dawid Pers Date: Thu, 29 Jan 2026 16:57:49 +0100 Subject: [PATCH 5/5] fix --- .../StoryContentBlocks/OrderedListBlock.astro | 11 ++++++----- .../StoryContentBlocks/UnorderedListBlock.astro | 12 ++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components/widgets/Story/StoryContent/StoryContentBlocks/OrderedListBlock.astro b/src/components/widgets/Story/StoryContent/StoryContentBlocks/OrderedListBlock.astro index 98dba353..f6d83c99 100644 --- a/src/components/widgets/Story/StoryContent/StoryContentBlocks/OrderedListBlock.astro +++ b/src/components/widgets/Story/StoryContent/StoryContentBlocks/OrderedListBlock.astro @@ -16,15 +16,16 @@ export interface OrderedListBlockParams { startValue: number; }; } -let toRender: boolean | JSX.Element | String = false; +let toRender: boolean | JSX.Element | string = false; if (!blockData?.entries?.length) { toRender = WidgetHelper_renderEmptyComponent("OrderedListBlock"); +} else { + blockData.entries = await Promise.all(blockData.entries.map(async (entry) => { + let processed = await LinkReplacerHelper_replaceLinks(context, entry); + return SeoLinkWhitelistHelper_processLinks(context, processed); + })); } -blockData.entries = await Promise.all(blockData.entries.map(async (entry) => { - let processed = await LinkReplacerHelper_replaceLinks(context, entry); - return SeoLinkWhitelistHelper_processLinks(context, processed); -})); --- { diff --git a/src/components/widgets/Story/StoryContent/StoryContentBlocks/UnorderedListBlock.astro b/src/components/widgets/Story/StoryContent/StoryContentBlocks/UnorderedListBlock.astro index 1a6ed882..3e0bbea8 100644 --- a/src/components/widgets/Story/StoryContent/StoryContentBlocks/UnorderedListBlock.astro +++ b/src/components/widgets/Story/StoryContent/StoryContentBlocks/UnorderedListBlock.astro @@ -15,16 +15,16 @@ export interface UnorderedListBlockParams { styleType: string; }; } -let toRender: boolean | JSX.Element | String = false; +let toRender: boolean | JSX.Element | string = false; if (!blockData?.entries?.length) { toRender = WidgetHelper_renderEmptyComponent("UnorderedListBlock"); +} else { + blockData.entries = await Promise.all(blockData.entries.map(async (entry) => { + let processed = await LinkReplacerHelper_replaceLinks(context, entry); + return SeoLinkWhitelistHelper_processLinks(context, processed); + })); } - -blockData.entries = await Promise.all(blockData.entries.map(async (entry) => { - let processed = await LinkReplacerHelper_replaceLinks(context, entry); - return SeoLinkWhitelistHelper_processLinks(context, processed); -})); --- {