simo 2 týždňov pred
rodič
commit
4e910f3ee2
2 zmenil súbory, kde vykonal 36 pridanie a 11 odobranie
  1. 19 1
      src/components/SettingsDialog.astro
  2. 17 10
      src/pages/[...cat].astro

+ 19 - 1
src/components/SettingsDialog.astro

@@ -192,6 +192,16 @@
 </div>
 
 <script is:inline>
+    const isEmbed = new URLSearchParams(window.location.search).get("embed") === "1";
+
+    if (isEmbed) {
+        // Embed mode: hide settings UI and avoid syncing/overwriting user cookies.
+        const settingsButton = document.getElementById("settings-button");
+        const settingsDialog = document.getElementById("settings-dialog");
+        if (settingsButton) settingsButton.style.display = "none";
+        if (settingsDialog) settingsDialog.style.display = "none";
+    }
+
     function setCookie(name, value, days = 365) {
         const date = new Date();
         date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
@@ -251,9 +261,12 @@
         }
     }
 
-    syncUserState();
+    if (!isEmbed) {
+        syncUserState();
+    }
 
     async function handleToken(jwt) {
+        if (isEmbed) return;
         try {
             const parts = jwt.credential.split(".");
             const payload = JSON.parse(atob(parts[1]));
@@ -276,6 +289,10 @@
 </script>
 
 <script>
+    const isEmbed = new URLSearchParams(window.location.search).get("embed") === "1";
+    if (isEmbed) {
+        // Embed mode: no settings interactions.
+    } else {
     const settingsButton = document.getElementById("settings-button");
     const settingsDialog = document.getElementById("settings-dialog");
     const closeSettings = document.getElementById("close-settings");
@@ -910,6 +927,7 @@
             }
         }
     });
+    }
 </script>
 
 <style is:global>

+ 17 - 10
src/pages/[...cat].astro

@@ -29,17 +29,24 @@ const defaultArticles = {
 
 let articles: any;
 
-const stored = Astro.cookies.get("rssFeeds")?.json();
-if (stored) {
-    try {
-        const customSettings = stored;
-        articles = customSettings;
-    } catch (e) {
-        console.error("Failed to parse stored RSS feeds, using defaults", e);
+const isEmbed = Astro.url.searchParams.get("embed") === "1";
+
+if (isEmbed) {
+    // Embed mode: ignore user-customized feeds and use built-in defaults.
+    articles = defaultArticles;
+} else {
+    const stored = Astro.cookies.get("rssFeeds")?.json();
+    if (stored) {
+        try {
+            const customSettings = stored;
+            articles = customSettings;
+        } catch (e) {
+            console.error("Failed to parse stored RSS feeds, using defaults", e);
+            articles = defaultArticles;
+        }
+    } else {
         articles = defaultArticles;
     }
-} else {
-    articles = defaultArticles;
 }
 
 articles.All = {
@@ -58,7 +65,7 @@ cat = !cat ? "/" : cat;
 ---
 
 <Layout>
-    <SettingsDialog />
+    {!isEmbed && <SettingsDialog />}
 
     <PopUpBox title="test" content="content" />