diff --git a/mindspace-page-tag.mjs b/mindspace-page-tag.mjs index c597dad..e3cc082 100644 --- a/mindspace-page-tag.mjs +++ b/mindspace-page-tag.mjs @@ -31,6 +31,24 @@ export function ensurePlatformBrandPageTags(html) { }); } +export function hasPlatformBrandMarker(html) { + return new RegExp( + `${MINDSPACE_PAGE_TAG_ATTR}\\s*=\\s*["']${MINDSPACE_PAGE_TAG_PLATFORM_BRAND}["']`, + 'i', + ).test(String(html ?? '')); +} + +/** Append the platform brand footer when authors omitted data-mindspace-page-tag. */ +export function ensurePlatformBrandFooter(html) { + const normalized = ensurePlatformBrandPageTags(html); + if (hasPlatformBrandMarker(normalized)) return normalized; + const footer = `
${PLATFORM_BRAND_TEXT}
`; + if (/<\/body>/i.test(normalized)) { + return normalized.replace(/<\/body>/i, `${footer}\n