-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: google adsense & google analytics
- Loading branch information
Showing
3 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script setup lang="ts"> | ||
// https://github.com/Justin3go/justin3go.github.io/commit/13a08c192be464f2052efd8f1da9547d4184eede | ||
// https://juejin.cn/post/7363078360786370599 | ||
import { nextTick, onMounted } from 'vue'; | ||
defineOptions({ | ||
name: 'VAd', | ||
}); | ||
onMounted(() => { | ||
nextTick(() => { | ||
const script = document.createElement('script'); | ||
script.innerHTML = `(adsbygoogle = window.adsbygoogle || []).push({});`; | ||
document.querySelector('#google-ads')!.append(script); | ||
}); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div id="google-ads"> | ||
<ins | ||
class="adsbygoogle" | ||
data-ad-client="ca-pub-3102250747488251" | ||
data-ad-format="auto" | ||
data-ad-slot="3708961821" | ||
data-full-width-responsive="true" | ||
style="display: block" | ||
></ins> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
#google-ads { | ||
padding: 12px; | ||
border-left: 1px solid var(--vp-c-divider); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
// https://vitepress.dev/guide/custom-theme | ||
import type { Theme } from "vitepress"; | ||
import DefaultTheme from "vitepress/theme"; | ||
import "./custom.css"; | ||
import type {EnhanceAppContext, Theme} from 'vitepress' | ||
import DefaultTheme from 'vitepress/theme'; | ||
import { h } from 'vue'; | ||
import VAd from './VAd.vue'; | ||
import './custom.css'; | ||
|
||
export default { | ||
extends: DefaultTheme, | ||
|
||
enhanceApp(ctx: EnhanceAppContext) { | ||
ctx.app.component('VAd', VAd) | ||
DefaultTheme.enhanceApp(ctx); | ||
}, | ||
|
||
Layout() { | ||
return h(DefaultTheme.Layout, null, { | ||
// 添加广告 | ||
'aside-bottom': () => [h(VAd)], | ||
}); | ||
}, | ||
|
||
} satisfies Theme; |