1// JavaScript para actualizar dinámicamente los meta tags 2window.updateMetaTags = function (metaTags) { 3 for (const [key, value] of Object.entries(metaTags)) { 4 let meta = document.querySelector(`meta[property="${key}"]`); 5 if (!meta) { 6 meta = document.createElement("meta"); 7 meta.setAttribute("property", key); 8 document.head.appendChild(meta); 9 } 10 meta.setAttribute("content", value); 11 } 12}; 13 14function setMetaContent(selector, attr, attrValue, content) { 15 let meta = document.querySelector(selector); 16 if (!meta) { 17 meta = document.createElement("meta"); 18 meta.setAttribute(attr, attrValue); 19 document.head.appendChild(meta); 20 } 21 meta.setAttribute("content", content); 22} 23 24function updateCategorySeoMeta(titleOrSeo, description) { 25 const seo = (titleOrSeo && typeof titleOrSeo === "object") 26 ? titleOrSeo 27 : { title: titleOrSeo, description: description }; 28 29 const title = seo.title || seo.metaTitle || seo.MetaTitle; 30 const desc = seo.description || seo.metaDescription || seo.MetaDescription; 31 32 if (title) { 33 document.title = title; 34 } 35 36 if (desc) { 37 setMetaContent('meta[name="description"]', "name", "description", desc); 38 } 39 40 const keywords = seo.keywords || seo.metaKeywords || seo.MetaKeywords || seo.KeywordsCategory; 41 if (keywords) { 42 setMetaContent('meta[name="keywords"]', "name", "keywords", keywords); 43 } 44 45 const pairs = [ 46 ['meta[property="og:title"]', "property", "og:title", seo.ogTitle || seo.OgTitle || title], 47 ['meta[property="og:description"]', "property", "og:description", seo.ogDescription || seo.OgDescription || desc], 48 ['meta[property="og:image"]', "property", "og:image", seo.ogImage || seo.OgImage], 49 ['meta[property="og:url"]', "property", "og:url", seo.ogUrl || seo.OgUrl], 50 ['meta[property="og:type"]', "property", "og:type", seo.ogType || seo.OgType], 51 ['meta[property="og:site_name"]', "property", "og:site_name", seo.ogSiteName || seo.OgSiteName], 52 ['meta[property="og:image:alt"]', "property", "og:image:alt", seo.ogImageAlt || seo.OgImageAlt], 53 ['meta[name="twitter:card"]', "name", "twitter:card", seo.twitterCard || seo.TwitterCard], 54 ['meta[name="twitter:site"]', "name", "twitter:site", seo.twitterSite || seo.TwitterSite], 55 ['meta[name="twitter:creator"]', "name", "twitter:creator", seo.twitterCreator || seo.TwitterCreator], 56 ['meta[name="twitter:title"]', "name", "twitter:title", seo.twitterTitle || seo.TwitterTitle || title], 57 ['meta[name="twitter:description"]', "name", "twitter:description", seo.twitterDescription || seo.TwitterDescription || desc], 58 ['meta[name="twitter:image"]', "name", "twitter:image", seo.twitterImage || seo.TwitterImage], 59 ['meta[name="twitter:url"]', "name", "twitter:url", seo.twitterUrl || seo.TwitterUrl] 60 ]; 61 62 for (const [selector, attr, attrValue, content] of pairs) { 63 if (content) { 64 setMetaContent(selector, attr, attrValue, content); 65 } 66 } 67}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.