Diferencia entre revisiones de «MediaWiki:Common.js»
De Enciclopedia Católica
Línea 6: | Línea 6: | ||
})(window, document, 'script', 'parsely'); | })(window, document, 'script', 'parsely'); | ||
− | (function ( | + | (function () { |
− | + | if (typeof mw === 'undefined') return; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | |||
mw.loader.using('mediawiki.util', function () { | mw.loader.using('mediawiki.util', function () { | ||
− | |||
if (mw.config.get('wgNamespaceNumber') !== 0) return; | if (mw.config.get('wgNamespaceNumber') !== 0) return; | ||
var title = mw.config.get('wgTitle'); | var title = mw.config.get('wgTitle'); | ||
var url = window.location.href; | var url = window.location.href; | ||
− | + | var datePublished = new Date(document.lastModified).toISOString(); | |
− | var datePublished = new Date(document.lastModified).toISOString() | + | |
− | + | ||
var metadata = { | var metadata = { | ||
Línea 30: | Línea 21: | ||
"headline": title, | "headline": title, | ||
"url": url, | "url": url, | ||
− | "author": { "name": | + | "author": { "name": "Enciclopedia Católica" }, |
"datePublished": datePublished, | "datePublished": datePublished, | ||
− | "articleSection": | + | "articleSection": "General" |
}; | }; | ||
Línea 39: | Línea 30: | ||
script.text = JSON.stringify(metadata); | script.text = JSON.stringify(metadata); | ||
document.head.appendChild(script); | document.head.appendChild(script); | ||
+ | |||
+ | console.log("✅ JSON-LD metadata inserted by Common.js"); | ||
}); | }); | ||
− | })( | + | })(); |
Revisión de 23:22 21 may 2025
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */ (function(s,p,a,r,s,e,l){ s['Parsely']=r;s[r]=s[r]||function(){(s[r].q=s[r].q||[]).push(arguments)}; e=p.createElement(a);l=p.getElementsByTagName(a)[0]; e.async=1;e.src='https://cdn.parsely.com/keys/ec.aciprensa.com/p.js';l.parentNode.insertBefore(e,l); })(window, document, 'script', 'parsely'); (function () { if (typeof mw === 'undefined') return; mw.loader.using('mediawiki.util', function () { if (mw.config.get('wgNamespaceNumber') !== 0) return; var title = mw.config.get('wgTitle'); var url = window.location.href; var datePublished = new Date(document.lastModified).toISOString(); var metadata = { "@context": "http://schema.org", "@type": "NewsArticle", "headline": title, "url": url, "author": { "name": "Enciclopedia Católica" }, "datePublished": datePublished, "articleSection": "General" }; var script = document.createElement('script'); script.type = 'application/ld+json'; script.text = JSON.stringify(metadata); document.head.appendChild(script); console.log("✅ JSON-LD metadata inserted by Common.js"); }); })();