Skip to content

Commit

Permalink
feat: integrate Google AdSense ads into PostLayout component
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-lcs committed Jan 21, 2025
1 parent ddfeaf9 commit ba0508b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions layouts/PostLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Tag from '@/components/Tag'
import siteMetadata from '@/data/siteMetadata'
import Comments from '@/components/comments'
import ScrollTopAndComment from '@/components/ScrollTopAndComment'
import { useEffect } from 'react'

const editUrl = (fileName) => `${siteMetadata.siteRepo}/blob/master/data/blog/${fileName}`

Expand All @@ -15,6 +16,10 @@ const postDateTemplate = { weekday: 'long', year: 'numeric', month: 'long', day:
export default function PostLayout({ frontMatter, authorDetails, next, prev, children }) {
const { slug, fileName, date, title, tags } = frontMatter

useEffect(() => {
;(window.adsbygoogle || []).push({})
}, [])

return (
<SectionContainer>
<BlogSEO
Expand Down Expand Up @@ -135,6 +140,14 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi
&larr; 返回博客列表
</Link>
</div>
<ins
className="adsbygoogle"
style={{ display: 'block', marginTop: '2rem' }}
data-ad-client="ca-pub-7669803939408201"
data-ad-slot="7543038000"
data-ad-format="auto"
data-full-width-responsive="true"
></ins>
</footer>
</div>
</div>
Expand Down

0 comments on commit ba0508b

Please sign in to comment.