From c640189041c864d472cab5008433c5496577bdb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Mon, 28 Sep 2026 17:55:13 +0200 Subject: [PATCH 1/3] simplify vitreum headtags stupid file --- vitreum/headtags.js | 87 +++++++-------------------------------------- 1 file changed, 12 insertions(+), 75 deletions(-) diff --git a/vitreum/headtags.js b/vitreum/headtags.js index 5f4019ecf..b6d69f0de 100644 --- a/vitreum/headtags.js +++ b/vitreum/headtags.js @@ -1,91 +1,28 @@ import React, { useEffect } from 'react'; -//old vitreum file, still imported in some pages - -const injectTag = (tag, props, children)=>{ - const injectNode = document.createElement(tag); - Object.entries(props).forEach(([key, val])=>injectNode[key] = val); - if(children) injectNode.appendChild(document.createTextNode(children)); - document.getElementsByTagName('head')[0].appendChild(injectNode); -}; - -const obj2props = (obj)=>Object.entries(obj) - .map(([k, v])=>`${k}="${v}"`) +const obj2props = (obj) => + Object.entries(obj) + .map(([k, v]) => `${k}="${v}"`) .join(' '); -const toStr = (chld)=>(Array.isArray(chld) ? chld.join('') : chld); -const onServer = typeof window === 'undefined'; let NamedTags = {}; -let UnnamedTags = []; -export const HeadComponents = { - Title({ children }) { - if(onServer) NamedTags.title = `${toStr(children)}`; - useEffect(()=>{ - document.title = toStr(children); - }, [children]); - return null; - }, - Favicon({ type = 'image/png', href = '', rel = 'icon', id = 'favicon' }) { - if(onServer) NamedTags.favicon = ``; - useEffect(()=>{ - document.getElementById(id).href = href; - }, [id, href]); - return null; - }, - Description({ children }) { - if(onServer) NamedTags.description = ``; - return null; - }, - Noscript({ children }) { - if(onServer) UnnamedTags.push(``); - return null; - }, - Script({ children = [], ...props }) { - if(onServer) { - UnnamedTags.push( - children.length - ? `` - : `