Diferencia entre revisiones de «MediaWiki:Common.js»
De Enciclopedia Católica
(Página creada con «→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]||functi...») |
|||
Línea 5: | Línea 5: | ||
e.async=1;e.src='https://cdn.parsely.com/keys/ec.aciprensa.com/p.js';l.parentNode.insertBefore(e,l); | e.async=1;e.src='https://cdn.parsely.com/keys/ec.aciprensa.com/p.js';l.parentNode.insertBefore(e,l); | ||
})(window, document, 'script', 'parsely'); | })(window, document, 'script', 'parsely'); | ||
+ | |||
+ | (function (w, d) { | ||
+ | // Incluir el script de Parse.ly | ||
+ | (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'); | ||
+ | |||
+ | // Esperar que la página cargue completamente | ||
+ | mw.loader.using('mediawiki.util', function () { | ||
+ | // Solo ejecutar en artículos (namespace 0) | ||
+ | if (mw.config.get('wgNamespaceNumber') !== 0) return; | ||
+ | |||
+ | var title = mw.config.get('wgTitle'); | ||
+ | var url = window.location.href; | ||
+ | var author = "Desconocido"; // Puedes cambiar esto si extraes autores | ||
+ | var datePublished = new Date(document.lastModified).toISOString(); // alternativa: usar un parser si tienes plantilla con fecha | ||
+ | var section = mw.config.get('wgCategories') || "General"; | ||
+ | |||
+ | var metadata = { | ||
+ | "@context": "http://schema.org", | ||
+ | "@type": "NewsArticle", | ||
+ | "headline": title, | ||
+ | "url": url, | ||
+ | "author": { "name": author }, | ||
+ | "datePublished": datePublished, | ||
+ | "articleSection": section | ||
+ | }; | ||
+ | |||
+ | var script = document.createElement('script'); | ||
+ | script.type = 'application/ld+json'; | ||
+ | script.text = JSON.stringify(metadata); | ||
+ | document.head.appendChild(script); | ||
+ | }); | ||
+ | })(window, document); |
Revisión de 22:45 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 (w, d) { // Incluir el script de Parse.ly (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'); // Esperar que la página cargue completamente mw.loader.using('mediawiki.util', function () { // Solo ejecutar en artículos (namespace 0) if (mw.config.get('wgNamespaceNumber') !== 0) return; var title = mw.config.get('wgTitle'); var url = window.location.href; var author = "Desconocido"; // Puedes cambiar esto si extraes autores var datePublished = new Date(document.lastModified).toISOString(); // alternativa: usar un parser si tienes plantilla con fecha var section = mw.config.get('wgCategories') || "General"; var metadata = { "@context": "http://schema.org", "@type": "NewsArticle", "headline": title, "url": url, "author": { "name": author }, "datePublished": datePublished, "articleSection": section }; var script = document.createElement('script'); script.type = 'application/ld+json'; script.text = JSON.stringify(metadata); document.head.appendChild(script); }); })(window, document);