Files
zeekay 83375ef557 Rebrand Lux explorer: disable Blockscout title suffix, ads, update footer links
- Disable 'Blockscout' title suffix by default (NEXT_PUBLIC_PROMOTE_BLOCKSCOUT_IN_TITLE)
- Disable banner and text ads by default
- Update footer links to point to Lux Network resources
- Change GitHub links from blockscout to luxfi
2026-01-23 16:02:47 -08:00

106 lines
2.9 KiB
TypeScript

import type { Feature } from './types';
import type { AdButlerConfig } from 'types/client/adButlerConfig';
import { SUPPORTED_AD_BANNER_PROVIDERS } from 'types/client/adProviders';
import type { AdBannerProviders, AdBannerAdditionalProviders } from 'types/client/adProviders';
import app from '../app';
import { getEnvValue, parseEnvJson } from '../utils';
const provider: AdBannerProviders = (() => {
const envValue = getEnvValue('NEXT_PUBLIC_AD_BANNER_PROVIDER') as AdBannerProviders;
// Lux fork: disable ads by default
return envValue && SUPPORTED_AD_BANNER_PROVIDERS.includes(envValue) ? envValue : 'none';
})();
const additionalProvider = getEnvValue('NEXT_PUBLIC_AD_BANNER_ADDITIONAL_PROVIDER') as AdBannerAdditionalProviders;
const isSpecifyEnabled = getEnvValue('NEXT_PUBLIC_AD_BANNER_ENABLE_SPECIFY') === 'true';
const title = 'Banner ads';
type AdsBannerFeatureProviderPayload = {
provider: Exclude<AdBannerProviders, 'adbutler' | 'none'>;
} | {
provider: 'adbutler';
adButler: {
config: {
desktop: AdButlerConfig;
mobile: AdButlerConfig;
};
};
} | {
provider: Exclude<AdBannerProviders, 'adbutler' | 'none'>;
additionalProvider: 'adbutler';
adButler: {
config: {
desktop: AdButlerConfig;
mobile: AdButlerConfig;
};
};
};
type AdsBannerFeaturePayload = AdsBannerFeatureProviderPayload & {
isSpecifyEnabled: boolean;
};
const config: Feature<AdsBannerFeaturePayload> = (() => {
if (app.isPrivateMode) {
return Object.freeze({
title,
isEnabled: false,
});
}
if (provider === 'adbutler') {
const desktopConfig = parseEnvJson<AdButlerConfig>(getEnvValue('NEXT_PUBLIC_AD_ADBUTLER_CONFIG_DESKTOP'));
const mobileConfig = parseEnvJson<AdButlerConfig>(getEnvValue('NEXT_PUBLIC_AD_ADBUTLER_CONFIG_MOBILE'));
if (desktopConfig && mobileConfig) {
return Object.freeze({
title,
isEnabled: true,
provider,
adButler: {
config: {
desktop: desktopConfig,
mobile: mobileConfig,
},
},
isSpecifyEnabled,
});
}
} else if (provider !== 'none') {
if (additionalProvider === 'adbutler') {
const desktopConfig = parseEnvJson<AdButlerConfig>(getEnvValue('NEXT_PUBLIC_AD_ADBUTLER_CONFIG_DESKTOP'));
const mobileConfig = parseEnvJson<AdButlerConfig>(getEnvValue('NEXT_PUBLIC_AD_ADBUTLER_CONFIG_MOBILE'));
return Object.freeze({
title,
isEnabled: true,
provider,
additionalProvider,
adButler: {
config: {
desktop: desktopConfig,
mobile: mobileConfig,
},
},
isSpecifyEnabled,
});
}
return Object.freeze({
title,
isEnabled: true,
provider,
isSpecifyEnabled,
});
}
return Object.freeze({
title,
isEnabled: false,
});
})();
export default config;