Skip to content

Commit a00c360

Browse files
committed
feat: conditionally render ads based on date
1 parent 04f7e2c commit a00c360

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/pages/index.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Card } from '@blueprintjs/core'
22

3+
import dayjs from 'dayjs'
34
import { ComponentType } from 'react'
45

56
import { CardTitle } from 'components/CardTitle'
@@ -67,16 +68,20 @@ export const IndexPage: ComponentType = withGlobalErrorBoundary(() => {
6768
)
6869
})
6970

70-
const Ads = () => (
71-
<a
72-
className="block relative"
73-
href="https://gad.netease.com/gad/access?project_id=201005304&s=SppRGFTnJ1VxfSFEZWE6hY3pO4gn&code_type=1"
74-
target="_blank"
75-
rel="noreferrer"
76-
>
77-
<img src="/ads_mumu.jpg" alt="MuMu模拟器" />
78-
<div className="absolute bottom-2 right-2 border border-current rounded text-[10px] text-zinc-300 px-1">
79-
广告
80-
</div>
81-
</a>
82-
)
71+
const Ads =
72+
dayjs().isAfter('2025-03-02 00:00:00+8') &&
73+
dayjs().isBefore('2025-04-02 00:00:00+8')
74+
? () => (
75+
// eslint-disable-next-line react/jsx-no-target-blank
76+
<a
77+
className="block relative"
78+
href="https://gad.netease.com/gad/access?project_id=201005304&s=SppRGFTnJ1VxfSFEZWE6hY3pO4gn&code_type=1"
79+
target="_blank"
80+
>
81+
<img src="/ads_mumu.jpg" alt="MuMu模拟器" />
82+
<div className="absolute bottom-2 right-2 border border-current rounded text-[10px] text-zinc-300 px-1">
83+
广告
84+
</div>
85+
</a>
86+
)
87+
: () => null

0 commit comments

Comments
 (0)