Skip to content

Commit

Permalink
Merge branch 'tangly1024:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeafter619 authored Nov 26, 2023
2 parents 1a183b9 + 23ac219 commit 3c910da
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions themes/simple/components/BlogListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import Link from 'next/link'
import { BlogItem } from './BlogItem'
import { AdSlot } from '@/components/GoogleAdsense'
import { siteConfig } from '@/lib/config'
import CONFIG from '../config'

export const BlogListPage = props => {
const { page = 1, posts, postCount } = props
const router = useRouter()
const totalPage = Math.ceil(postCount / parseInt(siteConfig('POSTS_PER_PAGE')))
const currentPage = +page

// 博客列表嵌入广告
const SIMPLE_POST_AD_ENABLE = siteConfig('SIMPLE_POST_AD_ENABLE', false, CONFIG)

const showPrev = currentPage > 1
const showNext = page < totalPage
const pagePrefix = router.asPath.split('?')[0].replace(/\/page\/[1-9]\d*/, '').replace(/\/$/, '')
Expand All @@ -20,9 +24,9 @@ export const BlogListPage = props => {

<div id="posts-wrapper">
{posts?.map((p, index) => (<div key={p.id}>
{(index + 1) % 3 === 0 && <AdSlot type='in-article' />}
{ (index + 1) === 4 && <AdSlot type='flow'/>}
<BlogItem post={p} />
{SIMPLE_POST_AD_ENABLE && (index + 1) % 3 === 0 && <AdSlot type='in-article' />}
{SIMPLE_POST_AD_ENABLE && (index + 1) === 4 && <AdSlot type='flow' />}
<BlogItem post={p} />
</div>))}

</div>
Expand Down
2 changes: 2 additions & 0 deletions themes/simple/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const CONFIG = {

SIMPLE_AUTHOR_LINK: process.env.NEXT_PUBLIC_AUTHOR_LINK || '#',

SIMPLE_POST_AD_ENABLE: process.env.NEXT_PUBLIC_SIMPLE_POST_AD_ENABLE || false, // 文章列表是否插入广告

// 菜单配置
SIMPLE_MENU_CATEGORY: true, // 显示分类
SIMPLE_MENU_TAG: true, // 显示标签
Expand Down
4 changes: 3 additions & 1 deletion themes/simple/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Transition } from '@headlessui/react'
import { Style } from './style'
import replaceSearchResult from '@/components/Mark'
import CommonHead from '@/components/CommonHead'
import WWAds from '@/components/WWAds'

/**
* 基础布局
Expand Down Expand Up @@ -172,7 +173,8 @@ const LayoutSlug = props => {
<ArticleInfo post={post} />

{/* 广告嵌入 */}
<AdSlot type={'in-article'} />
{/* <AdSlot type={'in-article'} /> */}
<WWAds orientation="horizontal" className="w-full" />

{/* Notion文章主体 */}
{!lock && <NotionPage post={post} />}
Expand Down

1 comment on commit 3c910da

@vercel
Copy link

@vercel vercel bot commented on 3c910da Nov 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.