From d5bf4217a88dd8caf5bd056cb47026301b5bffec Mon Sep 17 00:00:00 2001 From: Ayo Date: Wed, 27 Aug 2025 09:02:23 +0200 Subject: [PATCH] feat: under maintenance --- src/consts.ts | 2 +- src/pages/index.astro | 74 +++++--------------------------------- src/pages/index.astro.bkup | 74 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 67 deletions(-) create mode 100644 src/pages/index.astro.bkup diff --git a/src/consts.ts b/src/consts.ts index e5e5451..f2b7dc5 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -6,4 +6,4 @@ export const SITE_AUTHOR_MASTODON = 'https://social.ayco.io/@ayo' export const SITE_PROJECT_REPO = 'https://github.com/ayoayco/Cozy' export const SITE_DESCRIPTION = 'The Web is Yours.' -export const VERSION = 'Drooling-Dogs' +export const VERSION = 'Exhilirating-Experience' diff --git a/src/pages/index.astro b/src/pages/index.astro index d45f8a5..a56c384 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,74 +1,16 @@ --- -import { createClient, type RedisJSON } from 'redis' -import { type ArticleData, extract } from '@extractus/article-extractor' - -import AddressBar from '../components/AddressBar.astro' -import Post from '../components/Post.astro' import App from '../layouts/App.astro' import Library from '../components/Library.astro' import Footer from '../components/Footer.astro' - -// Initialize Redis client -const client = createClient() -client.on('error', (err) => console.error('Redis Client Error', err)) -await client.connect() - -// Disable prerendering for dynamic content -export const prerender = false - -// Get URL parameter from query string -let url = Astro.url.searchParams.get('url') -let article: ArticleData | null = { url: '/' } - -// Handle redirect loops by extracting URL from nested parameters -while (url?.startsWith(Astro.url.origin)) { - try { - // Parse the URL to extract search parameters - const parsedUrl = new URL(url) - url = parsedUrl.searchParams.get('url') - } catch { - // If URL parsing fails, break the loop - console.error('Failed to parse URL:', url) - break - } -} - -// Process article extraction only if a valid URL is provided -if (url && url !== '/' && url !== '') { - const cacheKey = 'cozy:url:' + url - - try { - // Check if article exists in Redis cache - const exists = await client.exists(cacheKey) - - if (exists) { - // Retrieve cached article data - article = (await client.json.get(cacheKey)) as ArticleData - console.log('>>> Using cached content', article.url) - } else { - // Fetch article from the web - article = await extract(url) - console.log('>>> Using fetched content', article?.url) - - if (article !== null && article.url) { - // Cache the fetched article in Redis - await client.json.set(cacheKey, '$', article as RedisJSON) - console.log('>>> Added to cache', article.url) - } - } - } catch (error) { - // Log error and continue with null article - console.error('Error processing article:', error) - article = null - } -} --- - - -
- -
- + +

Under Maintenance

+

+ Currently performing scheduled maintenance, working to improve your + experience. Please check back soon. We apologize for any inconvenience this + may cause. +

+