From 542ef614e00957a8cf688553b12ff13e20d7316e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81ngel?=
<136946098+nubesurrealista@users.noreply.github.com>
Date: Thu, 19 Dec 2024 11:56:45 -0400
Subject: [PATCH] Actualizar index.html
---
index.html | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/index.html b/index.html
index 75fe1cc..1b320df 100644
--- a/index.html
+++ b/index.html
@@ -90,6 +90,21 @@
transform: scale(1.05);
}
+ .link-preview {
+ margin-top: 10px;
+ padding: 10px;
+ border: 1px solid var(--link-color);
+ border-radius: 5px;
+ background-color: var(--background-color);
+ color: var(--text-color);
+ }
+
+ .link-preview img {
+ max-width: 100%;
+ height: auto;
+ border-radius: 5px;
+ }
+
#theme-toggle {
position: fixed;
top: 10px;
@@ -193,6 +208,7 @@
Mis Toots ${url}`;
+ });
+ }
+
+ async function fetchLinkPreview(url) {
+ try {
+ const response = await fetch(`https://api.linkpreview.net/?key=${linkPreviewApiKey}&q=${encodeURIComponent(url)}`);
+ if (response.ok) {
+ return response.json();
+ } else {
+ throw new Error('Error fetching link preview');
+ }
+ } catch (error) {
+ console.error('Error fetching link preview:', error);
+ return null;
+ }
+ }
+
+ async function generateLinkPreviews(contentDiv) {
+ const links = contentDiv.querySelectorAll('a');
+ for (const link of links) {
+ const url = link.href;
+ const previewData = await fetchLinkPreview(url);
+ if (previewData) {
+ const previewHtml = `
+
+
+
${previewData.title}
+
${previewData.description}
+
+ `;
+ link.insertAdjacentHTML('afterend', previewHtml);
+ }
+ }
+ }
+
async function loadToots() {
const errorDiv = document.getElementById("error-message");
const contentDiv = document.getElementById("rss-content");
@@ -230,6 +285,7 @@ Mis Toots