Skip to content

Commit

Permalink
chore: Add google ads
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Apr 1, 2024
1 parent bdb8dc6 commit 1a961a1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
11 changes: 3 additions & 8 deletions website/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export default defineConfig({
],
},
],
components: {
TableOfContents: "./src/components/starlight/TableOfContents.astro",
},
head: [
{
tag: "script",
Expand All @@ -114,14 +117,6 @@ export default defineConfig({
gtag('config', '${googleAnalyticsId}');
`,
},
{
tag: "script",
attrs: {
src: `https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6049036475236211`,
async: true,
crossorigin: "anonymous",
},
},
],
}),
tailwind({
Expand Down
1 change: 0 additions & 1 deletion website/public/ads.txt

This file was deleted.

20 changes: 20 additions & 0 deletions website/src/components/starlight/TableOfContents.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
import type { Props } from "@astrojs/starlight/props";
import AstrolightTableOfContents from "@astrojs/starlight/components/TableOfContents.astro";
---

<AstrolightTableOfContents {...Astro.props} />
<script
async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6049036475236211"
crossorigin="anonymous"></script>
<ins
class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-6049036475236211"
data-ad-slot="3475386518"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
6 changes: 6 additions & 0 deletions website/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />

declare let adsbygoogle: any;

interface Window {
adsbygoogle: any;
}

0 comments on commit 1a961a1

Please sign in to comment.