From 64f258d2fb758b7eab5403a871d946724b379812 Mon Sep 17 00:00:00 2001 From: Autoblogia Bot Date: Tue, 19 May 2026 23:10:32 +0000 Subject: [PATCH] feat(theme): rewrite appearance linkage in user repo --- Template-01/index.html | 112 +++++++++++++++++++++++++---------------- Template-02/index.html | 112 +++++++++++++++++++++++++---------------- 2 files changed, 136 insertions(+), 88 deletions(-) diff --git a/Template-01/index.html b/Template-01/index.html index a20dba5..19826b1 100644 --- a/Template-01/index.html +++ b/Template-01/index.html @@ -10,50 +10,74 @@ - - + css += " +:root { " + + "--font-sans: '" + settings.fontFamily + "', sans-serif !important; " + + "--font-serif: '" + settings.fontFamily + "', serif !important; " + + "--font-mono: '" + settings.fontFamily + "', monospace !important; " + + "} * { font-family: '" + settings.fontFamily + "', sans-serif !important; }"; + } + let styleNode = document.getElementById('dynamic-theme-style'); + if (!styleNode) { styleNode = document.createElement('style'); styleNode.id = 'dynamic-theme-style'; document.head.appendChild(styleNode); } + styleNode.innerHTML = css; + } + + window.addEventListener('message', (event) => { + if (event.data && event.data.type === 'UPDATE_APPEARANCE') { + applySettings(event.data.settings); + } + }); + + window.parent.postMessage({ type: 'IFRAME_READY' }, '*'); + + // Fetch on load + try { + const host = window.location.hostname; + const SUPABASE_URL = 'https://ccfezpxxmwpngqhlsbxz.supabase.co'; + const SUPABASE_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNjZmV6cHh4bXdwbmdxaGxzYnh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzU2ODk4NTcsImV4cCI6MjA5MTI2NTg1N30.TqXoUsunJoX9xQwOOq3PTugltyrMGn1OrZysO6C9hRM'; + fetch(SUPABASE_URL + '/rest/v1/sites?select=settings&custom_domain=ilike.*' + host + '*', { + headers: { + 'apikey': SUPABASE_KEY, + 'Authorization': 'Bearer ' + SUPABASE_KEY + } + }).then(r => r.json()).then(data => { + if (data && data.length > 0 && data[0].settings) { + applySettings(data[0].settings); + } + }).catch(console.error); + } catch(e) {} + + diff --git a/Template-02/index.html b/Template-02/index.html index 4694e42..1550a1b 100644 --- a/Template-02/index.html +++ b/Template-02/index.html @@ -10,50 +10,74 @@ - - + css += " +:root { " + + "--font-sans: '" + settings.fontFamily + "', sans-serif !important; " + + "--font-serif: '" + settings.fontFamily + "', serif !important; " + + "--font-mono: '" + settings.fontFamily + "', monospace !important; " + + "} * { font-family: '" + settings.fontFamily + "', sans-serif !important; }"; + } + let styleNode = document.getElementById('dynamic-theme-style'); + if (!styleNode) { styleNode = document.createElement('style'); styleNode.id = 'dynamic-theme-style'; document.head.appendChild(styleNode); } + styleNode.innerHTML = css; + } + + window.addEventListener('message', (event) => { + if (event.data && event.data.type === 'UPDATE_APPEARANCE') { + applySettings(event.data.settings); + } + }); + + window.parent.postMessage({ type: 'IFRAME_READY' }, '*'); + + // Fetch on load + try { + const host = window.location.hostname; + const SUPABASE_URL = 'https://ccfezpxxmwpngqhlsbxz.supabase.co'; + const SUPABASE_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNjZmV6cHh4bXdwbmdxaGxzYnh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzU2ODk4NTcsImV4cCI6MjA5MTI2NTg1N30.TqXoUsunJoX9xQwOOq3PTugltyrMGn1OrZysO6C9hRM'; + fetch(SUPABASE_URL + '/rest/v1/sites?select=settings&custom_domain=ilike.*' + host + '*', { + headers: { + 'apikey': SUPABASE_KEY, + 'Authorization': 'Bearer ' + SUPABASE_KEY + } + }).then(r => r.json()).then(data => { + if (data && data.length > 0 && data[0].settings) { + applySettings(data[0].settings); + } + }).catch(console.error); + } catch(e) {} + +