mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: some ads basework
This commit is contained in:
1 parent
e52063c12d
commit
9923efe8ab
4 files changed
+64
-73
No files matched your search
@@ -1,71 +1,25 @@
|
|||||||
import { type BoxProps } from '@radix-ui/themes';
|
import { Box, type BoxProps } from '@radix-ui/themes';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
export enum AdType {
|
type AdProps = BoxProps & {};
|
||||||
MediumRectangleHorizontalPurple = 738182777,
|
|
||||||
LeaderboardHorizontalPurple = 84051521,
|
export function Ad({ ...props }: AdProps) {
|
||||||
WideSkyscraperVerticalPurple = 1755617140,
|
const id = 'test';
|
||||||
HalfPageVerticalPurple = 880185176,
|
|
||||||
}
|
useEffect(() => {
|
||||||
|
(window as any).nitroAds.createAd('test', {
|
||||||
// const AD_DIMENSIONS: Record<AdType, Vector2Tuple> = {
|
demo: true,
|
||||||
// [AdType.MediumRectangleHorizontalPurple]: [300, 250],
|
refreshTime: 30,
|
||||||
// [AdType.LeaderboardHorizontalPurple]: [728, 90],
|
renderVisibleOnly: false,
|
||||||
// [AdType.WideSkyscraperVerticalPurple]: [160, 600],
|
sizes: [],
|
||||||
// [AdType.HalfPageVerticalPurple]: [300, 600],
|
report: {
|
||||||
// };
|
enabled: true,
|
||||||
|
icon: true,
|
||||||
type AdProps = BoxProps & {
|
wording: 'Report Ad',
|
||||||
type: AdType;
|
position: 'top-right',
|
||||||
};
|
},
|
||||||
|
});
|
||||||
export function Ad({}: AdProps) {
|
}, [id]);
|
||||||
return null;
|
|
||||||
|
return <Box id={id} {...props} />;
|
||||||
// const id = useRef(uniqueId());
|
|
||||||
// const dimensions = AD_DIMENSIONS[type];
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// (window as any).msAdsQueue.push(function () {
|
|
||||||
// (window as any).mmnow.render({
|
|
||||||
// adUnitId: type,
|
|
||||||
// elementId: `${type}-${id.current}`,
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// }, [type]);
|
|
||||||
|
|
||||||
// return (
|
|
||||||
// <Box
|
|
||||||
// position="relative"
|
|
||||||
// width={`${dimensions[0]}px`}
|
|
||||||
// height={`${dimensions[1]}px`}
|
|
||||||
// style={{
|
|
||||||
// outline: '1px solid var(--gray-3)',
|
|
||||||
// borderRadius: 'var(--radius-1)',
|
|
||||||
// background: `url(${imgur('DK21EHY')})`,
|
|
||||||
|
|
||||||
// ...style,
|
|
||||||
// }}
|
|
||||||
// {...props}
|
|
||||||
// >
|
|
||||||
// <Text
|
|
||||||
// color="gray"
|
|
||||||
// style={{
|
|
||||||
// position: 'absolute',
|
|
||||||
// top: '50%',
|
|
||||||
// left: '50%',
|
|
||||||
// transform: 'translate(-50%, -50%)',
|
|
||||||
// }}
|
|
||||||
// align="center"
|
|
||||||
// >
|
|
||||||
// Advertisement
|
|
||||||
// </Text>
|
|
||||||
|
|
||||||
// <Box
|
|
||||||
// width={`${dimensions[0]}px`}
|
|
||||||
// height={`${dimensions[1]}px`}
|
|
||||||
// position="relative"
|
|
||||||
// id={`${type}-${id.current}`}
|
|
||||||
// />
|
|
||||||
// </Box>
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
{/* google analytics */}
|
||||||
<script
|
<script
|
||||||
is:inline
|
is:inline
|
||||||
async
|
async
|
||||||
@@ -11,3 +12,24 @@
|
|||||||
gtag('js', new Date());
|
gtag('js', new Date());
|
||||||
gtag('config', 'G-GL2JVHCGPQ');
|
gtag('config', 'G-GL2JVHCGPQ');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{/* nitro ads */}
|
||||||
|
<script data-cfasync="false" is:inline>
|
||||||
|
window.nitroAds = window.nitroAds || {
|
||||||
|
createAd: function () {
|
||||||
|
return new Promise((e) => {
|
||||||
|
window.nitroAds.queue.push(['createAd', arguments, e]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addUserToken: function () {
|
||||||
|
window.nitroAds.queue.push(['addUserToken', arguments]);
|
||||||
|
},
|
||||||
|
queue: [],
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script
|
||||||
|
is:inline
|
||||||
|
data-cfasync="false"
|
||||||
|
async
|
||||||
|
src={`https://s.nitropay.com/ads-${import.meta.env.PUBLIC_NITROPAY_ID}.js`}
|
||||||
|
></script>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import type { APIContext } from 'astro';
|
||||||
|
|
||||||
|
export const prerender = false;
|
||||||
|
|
||||||
|
export async function GET({}: APIContext) {
|
||||||
|
const response = await fetch(
|
||||||
|
`https://api.nitropay.com/v1/ads-${import.meta.env.PUBLIC_NITROPAY_ID}.txt`,
|
||||||
|
);
|
||||||
|
const text = await response.text();
|
||||||
|
const date = new Date();
|
||||||
|
const content = `# Generated on ${date.toUTCString()}\n\n${text}`;
|
||||||
|
|
||||||
|
return new Response(content);
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { Box, Flex, Heading } from '@radix-ui/themes';
|
import { Box, Flex, Heading } from '@radix-ui/themes';
|
||||||
|
import { Ad } from '../components/Ad';
|
||||||
import HomeHero from '../components/HomeHero.astro';
|
import HomeHero from '../components/HomeHero.astro';
|
||||||
import { Plugs } from '../components/Plugs.tsx';
|
import { Plugs } from '../components/Plugs.tsx';
|
||||||
import ToolCard from '../components/ToolCard.astro';
|
import ToolCard from '../components/ToolCard.astro';
|
||||||
@@ -29,13 +30,13 @@ import RootLayout from '../layouts/RootLayout.astro';
|
|||||||
<ToolCard tool={tankPerformanceTool} />
|
<ToolCard tool={tankPerformanceTool} />
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<!-- {
|
{
|
||||||
!exempt && (
|
(
|
||||||
<Flex justify="center">
|
<Flex justify="center">
|
||||||
<AdMidSectionResponsive />
|
<Ad client:only="react" />
|
||||||
</Flex>
|
</Flex>
|
||||||
)
|
)
|
||||||
} -->
|
}
|
||||||
|
|
||||||
<Flex gap="4" direction={{ initial: 'column', sm: 'row' }}>
|
<Flex gap="4" direction={{ initial: 'column', sm: 'row' }}>
|
||||||
<ToolCard tool={sessionTool} />
|
<ToolCard tool={sessionTool} />
|
||||||
|
|||||||
Reference in new issue
Block a user