add ad space

enable with env VITE_SHOW_AD, VITE_AD_CONTENT_URL

I know this is controversial but eh
This commit is contained in:
Pas 2025-03-22 17:28:57 -06:00
parent c43462319c
commit 084691d0c4
2 changed files with 33 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import { HeroTitle } from "@/components/text/HeroTitle";
import { useIsTV } from "@/hooks/useIsTv";
import { useRandomTranslation } from "@/hooks/useRandomTranslation";
import { useSearchQuery } from "@/hooks/useSearchQuery";
import { conf } from "@/setup/config";
import { useBannerSize } from "@/stores/banner";
export interface HeroPartProps {
@ -99,6 +100,27 @@ export function HeroPart({ setIsSticky, searchParams }: HeroPartProps) {
</Sticky>
</div>
</div>
{/* Optional ad */}
{conf().SHOW_AD ? (
<div className="-mb-20 w-[16rem] mx-auto">
{conf().AD_CONTENT_URL.length !== 0 ? (
<a href={conf().AD_CONTENT_URL[0]}>
<img src={conf().AD_CONTENT_URL[1]} alt="ad for zaccounts" />
</a>
) : null}
<p className="text-xs text-type-dimmed text-center pt-2">
<a
href="https://discord.gg/mcjnJK98Gd"
target="_blank"
rel="noreferrer"
>
Your ad here ( _ᴗ)
</a>
</p>
</div>
) : null}
{/* End of ad */}
</ThinContainer>
);
}

View file

@ -25,6 +25,8 @@ interface Config {
ONBOARDING_PROXY_INSTALL_LINK: string;
ALLOW_AUTOPLAY: boolean;
ALLOW_FEBBOX_KEY: boolean;
SHOW_AD: boolean;
AD_CONTENT_URL: string;
}
export interface RuntimeConfig {
@ -46,6 +48,8 @@ export interface RuntimeConfig {
ONBOARDING_FIREFOX_EXTENSION_INSTALL_LINK: string | null;
ONBOARDING_PROXY_INSTALL_LINK: string | null;
ALLOW_FEBBOX_KEY: boolean;
SHOW_AD: boolean;
AD_CONTENT_URL: string[];
}
const env: Record<keyof Config, undefined | string> = {
@ -70,6 +74,8 @@ const env: Record<keyof Config, undefined | string> = {
HAS_ONBOARDING: import.meta.env.VITE_HAS_ONBOARDING,
ALLOW_AUTOPLAY: import.meta.env.VITE_ALLOW_AUTOPLAY,
ALLOW_FEBBOX_KEY: import.meta.env.VITE_ALLOW_FEBBOX_KEY,
SHOW_AD: import.meta.env.VITE_SHOW_AD,
AD_CONTENT_URL: import.meta.env.VITE_AD_CONTENT_URL,
};
function coerceUndefined(value: string | null | undefined): string | undefined {
@ -131,5 +137,10 @@ export function conf(): RuntimeConfig {
)
.filter((v) => v.length === 2), // The format is <beforeA>:<afterA>,<beforeB>:<afterB>
ALLOW_FEBBOX_KEY: getKey("ALLOW_FEBBOX_KEY", "false") === "true",
SHOW_AD: getKey("SHOW_AD", "false") === "true",
AD_CONTENT_URL: getKey("AD_CONTENT_URL", "")
.split(",")
.map((v) => v.trim())
.filter((v) => v.length > 0),
};
}