Skip to content

Commit

Permalink
feat: #1055 (seo);
Browse files Browse the repository at this point in the history
  • Loading branch information
migbash committed Feb 28, 2023
1 parent 47de950 commit ba2a23d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -101,6 +116,23 @@ NOTE: [HINT] use (CTRL+SPACE) to select a (class) (id) style from the global (ap
<p>
THIS IS SEO WIDGET CONTENT
</p>
<div>
{#each WIDGET_S_DATA?.fixtures as item1}
{#if item1?.urls && item1?.urls[server_side_language]}
<a href={item1?.urls[server_side_language]}>{item1?.id}</a>
{/if}
{#if item1?.tips && item1?.tips[server_side_language]}
<a href={item1?.tips[server_side_language]}>{item1?.id}</a>
{/if}
{/each}
</div>
<div>
{#each WIDGET_S_DATA?.leagues as item}
{#if item?.urls && item?.urls[server_side_language]}
<a href={item?.urls[server_side_language]}>{item?.id}</a>
{/if}
{/each}
</div>
</SeoBox>

<!-- <LivescoresLoader /> -->
Expand Down
3 changes: 3 additions & 0 deletions src/routes/[[lang=lang]]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 18 additions & 2 deletions src/routes/api/cache/home/livescores-v2/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ import {

import {
LS2_C_D_A,
LS2_C_S_A,
LS2_C_T_A
} from 'betarena-types/dist/redis/config.js';

/** @type {import('@sveltejs/kit').RequestHandler} */
export async function GET(req): Promise<unknown> {
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
Expand All @@ -29,7 +32,7 @@ export async function GET(req): Promise<unknown> {
}

// [ℹ] (translation - inc. SEO)
if (lang) {
if (lang && !seo) {
const response_cache =
await get_target_hset_cache_data(
LS2_C_T_A,
Expand All @@ -40,6 +43,19 @@ export async function GET(req): Promise<unknown> {
}
}

// [ℹ] (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);
}

0 comments on commit ba2a23d

Please sign in to comment.