Optimización del código
This commit is contained in:
@@ -1,261 +0,0 @@
|
|||||||
---
|
|
||||||
import RelatedPosts from "../components/PostsRelacionados.astro"; // Componente para posts relacionados
|
|
||||||
import Navbar from "../components/Navbar.astro";
|
|
||||||
import Footer from "../components/Footer.astro";
|
|
||||||
|
|
||||||
const { frontmatter } = Astro.props;
|
|
||||||
const headings = Astro.props.headings;
|
|
||||||
const description = frontmatter.descripcion;
|
|
||||||
|
|
||||||
// URLs para compartir en redes sociales
|
|
||||||
const shareUrl = new URL(Astro.url.pathname, Astro.site).toString();
|
|
||||||
const facebookShareUrl = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(shareUrl)}`;
|
|
||||||
const twitterShareUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl)}&text=${encodeURIComponent(frontmatter.titulo)}`;
|
|
||||||
const linkedinShareUrl = `https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(shareUrl)}&title=${encodeURIComponent(frontmatter.titulo)}`;
|
|
||||||
|
|
||||||
const blogJsonLd = {
|
|
||||||
"@context": "https://schema.org",
|
|
||||||
"@type": "BlogPosting",
|
|
||||||
"headline": frontmatter.titulo,
|
|
||||||
"image": frontmatter.imagen && new URL(frontmatter.imagen, Astro.site),
|
|
||||||
"datePublished": frontmatter.fecha,
|
|
||||||
"dateModified": frontmatter.fecha,
|
|
||||||
"author": {
|
|
||||||
"@type": "Person",
|
|
||||||
"name": frontmatter.autor
|
|
||||||
},
|
|
||||||
"publisher": {
|
|
||||||
"@type": "Organization",
|
|
||||||
"name": "Ecobjetivos",
|
|
||||||
"logo": {
|
|
||||||
"@type": "ImageObject",
|
|
||||||
"url": new URL('/logo.png', Astro.site)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description": description
|
|
||||||
};
|
|
||||||
---
|
|
||||||
|
|
||||||
<html lang="es">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>{frontmatter.titulo} - Ecobjetivos</title>
|
|
||||||
<link rel="icon" type="image/png" href="logo.png" />
|
|
||||||
<meta name="description" content={description} />
|
|
||||||
<link rel="canonical" href={new URL(Astro.url.pathname, Astro.site).toString()} />
|
|
||||||
|
|
||||||
<!-- Open Graph / Facebook -->
|
|
||||||
<meta property="og:type" content="article" />
|
|
||||||
<meta property="og:url" content={Astro.url} />
|
|
||||||
<meta property="og:title" content={frontmatter.titulo} />
|
|
||||||
<meta property="og:description" content={description} />
|
|
||||||
<meta property="og:image" content={frontmatter.imagen && new URL(frontmatter.imagen, Astro.site)} />
|
|
||||||
|
|
||||||
<!-- Twitter -->
|
|
||||||
<meta property="twitter:card" content="summary_large_image" />
|
|
||||||
<meta property="twitter:url" content={Astro.url} />
|
|
||||||
<meta property="twitter:title" content={frontmatter.titulo} />
|
|
||||||
<meta property="twitter:description" content={description} />
|
|
||||||
<meta property="twitter:image" content={frontmatter.imagen && new URL(frontmatter.imagen, Astro.site)} />
|
|
||||||
|
|
||||||
<!-- Google tag (gtag.js) -->
|
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-1JT18RF3R4"></script>
|
|
||||||
<script>
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
|
||||||
function gtag() {
|
|
||||||
dataLayer.push(arguments);
|
|
||||||
}
|
|
||||||
gtag("js", new Date());
|
|
||||||
gtag("config", "G-1JT18RF3R4");
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Structured Data for Google -->
|
|
||||||
<script type="application/ld+json" set:html={JSON.stringify(blogJsonLd)} />
|
|
||||||
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet" />
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: "Arial", sans-serif;
|
|
||||||
line-height: 1.6;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
.post-header {
|
|
||||||
background-color: #4caf50;
|
|
||||||
color: white;
|
|
||||||
padding: 2rem 0;
|
|
||||||
}
|
|
||||||
.post-content {
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
.post-content img {
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
margin: 1.5rem 0;
|
|
||||||
}
|
|
||||||
.post-meta {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
margin: 0px !important;
|
|
||||||
}
|
|
||||||
blockquote {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
border-left: 5px solid #4caf50;
|
|
||||||
padding: 1rem;
|
|
||||||
margin: 1rem 0;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
.table-of-contents {
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
|
||||||
border: 1px solid #e9ecef;
|
|
||||||
}
|
|
||||||
.table-of-contents h4 {
|
|
||||||
color: #2c3e50;
|
|
||||||
border-bottom: 2px solid #4caf50;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
||||||
.table-of-contents ul {
|
|
||||||
list-style-type: none;
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
.table-of-contents a {
|
|
||||||
color: #495057;
|
|
||||||
text-decoration: none;
|
|
||||||
display: block;
|
|
||||||
border-radius: 5px;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.table-of-contents a:hover {
|
|
||||||
color: #4caf50;
|
|
||||||
background-color: #e8f5e9;
|
|
||||||
padding-left: 0.6rem;
|
|
||||||
}
|
|
||||||
/* Estilos para la indentación visual */
|
|
||||||
.toc-level-2 { padding-left: 1.1rem; }
|
|
||||||
.toc-level-3 { padding-left: 2.1rem; }
|
|
||||||
.toc-level-4 { padding-left: 3.1rem; }
|
|
||||||
.toc-level-5 { padding-left: 4.1rem; }
|
|
||||||
.toc-level-6 { padding-left: 5.1rem; }
|
|
||||||
/* Líneas verticales para la indentación */
|
|
||||||
.toc-level-2,
|
|
||||||
.toc-level-3,
|
|
||||||
.toc-level-4,
|
|
||||||
.toc-level-5,
|
|
||||||
.toc-level-6 {
|
|
||||||
border-left: 2px solid #e9ecef;
|
|
||||||
margin-left: 0.5rem;
|
|
||||||
}
|
|
||||||
html { scroll-padding-top: 70px; }
|
|
||||||
img { max-width: 100%; height: auto; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<Navbar proyectos="/" />
|
|
||||||
|
|
||||||
<header class="post-header">
|
|
||||||
<div class="container">
|
|
||||||
<h1 class="display-4">{frontmatter.titulo}</h1>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main class="container my-5">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<article class="post-content" data-bs-spy="scroll" data-bs-target="#toc" data-bs-offset="70" tabindex="0">
|
|
||||||
<slot />
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-4">
|
|
||||||
<aside class="sticky-top" style="top: 5rem;">
|
|
||||||
<div class="d-none d-lg-block">
|
|
||||||
<!-- Se añade el id "toc" para ser usado por scrollspy -->
|
|
||||||
<div id="toc" class="table-of-contents p-3 mb-4">
|
|
||||||
<h4 class="mb-3 pb-2 fw-bold">Contenido</h4>
|
|
||||||
<ul class="m-0">
|
|
||||||
{headings.map((heading) => (
|
|
||||||
<li class={`mb-2 toc-level-${heading.depth}`}>
|
|
||||||
<a href={`#${heading.slug}`} class="py-1 px-2">
|
|
||||||
{heading.text}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card mb-4">
|
|
||||||
<div class="card-body">
|
|
||||||
<p class="post-meta">
|
|
||||||
<i class="fas fa-calendar-alt"></i>
|
|
||||||
{new Date(frontmatter.fecha).toLocaleDateString("es-ES", {
|
|
||||||
year: "numeric",
|
|
||||||
month: "long",
|
|
||||||
day: "numeric",
|
|
||||||
})}
|
|
||||||
|
|
|
||||||
<i class="fas fa-user"></i>
|
|
||||||
{frontmatter.autor}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
<h5 class="card-title">Compartir</h5>
|
|
||||||
<a
|
|
||||||
href={facebookShareUrl}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
class="btn btn-primary me-2"
|
|
||||||
>
|
|
||||||
<i class="fab fa-facebook-f fa-fw"></i>
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
href={twitterShareUrl}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
class="btn btn-info me-2"
|
|
||||||
>
|
|
||||||
<i class="fab fa-twitter fa-fw"></i>
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
href={linkedinShareUrl}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
class="btn btn-secondary"
|
|
||||||
>
|
|
||||||
<i class="fab fa-linkedin-in fa-fw"></i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<RelatedPosts currentPost={frontmatter} />
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<Footer />
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
<style is:global>
|
|
||||||
@import url("https://fonts.googleapis.com/css2?family=Inter+Tight:ital@0;1&display=swap");
|
|
||||||
@import url("https://fonts.googleapis.com/css2?family=Londrina+Sketch&display=swap");
|
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6, p, a {
|
|
||||||
font-family: "Inter Tight", sans-serif !important;
|
|
||||||
font-optical-sizing: auto;
|
|
||||||
font-weight: 400 !important;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
.londrina-sketch-regular {
|
|
||||||
font-family: "Londrina Sketch", sans-serif !important;
|
|
||||||
font-weight: 400;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
import Navbar from "../components/Navbar.astro";
|
import Navbar from "../../components/Navbar.astro";
|
||||||
import ListadoPosts from "../layouts/ListadoPosts.astro";
|
import ListadoPosts from "../../layouts/ListadoPosts.astro";
|
||||||
---
|
---
|
||||||
|
|
||||||
<html lang="es">
|
<html lang="es">
|
||||||
@@ -9,12 +9,6 @@ import ListadoPosts from "../layouts/ListadoPosts.astro";
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="generator" content={Astro.generator} />
|
<meta name="generator" content={Astro.generator} />
|
||||||
<link rel="icon" type="image/png" href="logo.png" />
|
<link rel="icon" type="image/png" href="logo.png" />
|
||||||
<link
|
|
||||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
|
||||||
rel="stylesheet"
|
|
||||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
|
||||||
crossorigin="anonymous"
|
|
||||||
/>
|
|
||||||
<link
|
<link
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
|
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
@@ -40,9 +34,5 @@ import ListadoPosts from "../layouts/ListadoPosts.astro";
|
|||||||
<Navbar />
|
<Navbar />
|
||||||
<ListadoPosts />
|
<ListadoPosts />
|
||||||
</main>
|
</main>
|
||||||
<script
|
|
||||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
|
|
||||||
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
|
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user