From ba2a23dbd2c4642dc8e7eb7e3a97824e4aecdd32 Mon Sep 17 00:00:00 2001
From: migbash <20924663+migbash@users.noreply.github.com>
Date: Tue, 28 Feb 2023 01:51:00 +0000
Subject: [PATCH] feat: #1055 (seo);
---
.../livescores-v2/Livescores_Widget.svelte | 32 +++++++++++++++++++
src/routes/[[lang=lang]]/+page.ts | 3 ++
.../api/cache/home/livescores-v2/+server.ts | 20 ++++++++++--
3 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/src/lib/components/page/home/livescores-v2/Livescores_Widget.svelte b/src/lib/components/page/home/livescores-v2/Livescores_Widget.svelte
index 05ad7fe66..e4be6747f 100644
--- a/src/lib/components/page/home/livescores-v2/Livescores_Widget.svelte
+++ b/src/lib/components/page/home/livescores-v2/Livescores_Widget.svelte
@@ -26,6 +26,7 @@ COMPONENT JS (w/ TS)
//#endregion ➤ Types Imports
import SeoBox from '$lib/components/SEO-Box.svelte';
+ import { platfrom_lang_ssr } from '$lib/utils/platform-functions';
import LivescoresLoader from './Livescores_Loader.svelte';
import LivescoresMain from './Livescores_Main.svelte';
@@ -41,6 +42,7 @@ COMPONENT JS (w/ TS)
// ~~~~~~~~~~~~~~~~~~~~~
let WIDGET_T_DATA: B_LS2_T = $page.data?.LIVESCORES_V2_T_DATA
+ let WIDGET_S_DATA: any = $page.data?.LIVESCORES_V2_SEO
let WIDGET_DATA: B_LS2_D
let NO_WIDGET_DATA: boolean = true // [ℹ] default (true)
@@ -80,6 +82,19 @@ COMPONENT JS (w/ TS)
//#region ➤ [ONE-OFF] [METHODS] [IF]
+ // ~~~~~~~~~~~~~~~~~~~~~
+ // (SSR) LANG SVELTE | IMPORTANT
+ // ~~~~~~~~~~~~~~~~~~~~~
+
+ let server_side_language = platfrom_lang_ssr(
+ $page?.route?.id,
+ $page?.error,
+ $page?.params?.lang
+ );
+ dlog(
+ `server_side_language: ${server_side_language}`
+ );
+
//#endregion ➤ [ONE-OFF] [METHODS] [IF]
//#region ➤ [REACTIVIY] [METHODS]
@@ -101,6 +116,23 @@ NOTE: [HINT] use (CTRL+SPACE) to select a (class) (id) style from the global (ap
THIS IS SEO WIDGET CONTENT
+
+ {#each WIDGET_S_DATA?.fixtures as item1}
+ {#if item1?.urls && item1?.urls[server_side_language]}
+
{item1?.id}
+ {/if}
+ {#if item1?.tips && item1?.tips[server_side_language]}
+
{item1?.id}
+ {/if}
+ {/each}
+
+
+ {#each WIDGET_S_DATA?.leagues as item}
+ {#if item?.urls && item?.urls[server_side_language]}
+
{item?.id}
+ {/if}
+ {/each}
+
diff --git a/src/routes/[[lang=lang]]/+page.ts b/src/routes/[[lang=lang]]/+page.ts
index bb6bbc2fa..cbc94f62c 100644
--- a/src/routes/[[lang=lang]]/+page.ts
+++ b/src/routes/[[lang=lang]]/+page.ts
@@ -38,6 +38,7 @@ export async function load({
`/api/cache/home/leagues_table?lang=${urlLang}`,
`/api/cache/home/seo_block?lang=${urlLang}`,
`/api/cache/home/livescores-v2?lang=${urlLang}`,
+ `/api/cache/home/livescores-v2?seo=true`,
// [ℹ] page validation check;
`/api/cache/_main_/pages_and_seo?url=${url.pathname}`,
// [ℹ] livescores
@@ -65,6 +66,7 @@ export async function load({
LEAGUES_TABLE_SCORES_SEO_DATA,
SEO_BLOCK_DATA,
LIVESCORES_V2_T_DATA,
+ LIVESCORES_V2_SEO,
VALID_URL,
LIVE_SCORES_DATA_DATA_SEO,
LIVE_SCORES_DATA_LEAGUES,
@@ -121,6 +123,7 @@ export async function load({
LEAGUES_TABLE_SCORES_SEO_DATA,
SEO_BLOCK_DATA,
LIVESCORES_V2_T_DATA,
+ LIVESCORES_V2_SEO,
LIVE_SCORES_DATA_DATA_SEO,
LIVE_SCORES_DATA_LEAGUES,
LIVE_SCORES_FOOTBALL_TRANSLATIONS,
diff --git a/src/routes/api/cache/home/livescores-v2/+server.ts b/src/routes/api/cache/home/livescores-v2/+server.ts
index 73621f4d0..5efeb2ece 100644
--- a/src/routes/api/cache/home/livescores-v2/+server.ts
+++ b/src/routes/api/cache/home/livescores-v2/+server.ts
@@ -7,6 +7,7 @@ import {
import {
LS2_C_D_A,
+ LS2_C_S_A,
LS2_C_T_A
} from 'betarena-types/dist/redis/config.js';
@@ -14,9 +15,11 @@ import {
export async function GET(req): Promise {
const lang: string =
req.url['searchParams'].get('lang');
+ const seo: string =
+ req.url['searchParams'].get('seo');
// [ℹ] (data)
- if (!lang) {
+ if (!lang && !seo) {
const response =
await get_target_string_cache_data(
LS2_C_D_A
@@ -29,7 +32,7 @@ export async function GET(req): Promise {
}
// [ℹ] (translation - inc. SEO)
- if (lang) {
+ if (lang && !seo) {
const response_cache =
await get_target_hset_cache_data(
LS2_C_T_A,
@@ -40,6 +43,19 @@ export async function GET(req): Promise {
}
}
+ // [ℹ] (data)
+ if (seo) {
+ const response =
+ await get_target_string_cache_data(
+ LS2_C_S_A
+ );
+ if (response) {
+ return json(response);
+ }
+ // [ℹ] otherwise, there is NO MATCHES available;
+ return json(null);
+ }
+
// [ℹ] should never happen;
return json(null);
}