Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a64bdc3

Browse files
committed
add adsense in feed code to last of posts-list
1 parent c64087a commit a64bdc3

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

โ€Ž_config.ymlโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pagination:
341341
# collection: 'posts'
342342

343343
# How many objects per paginated page, used to be `paginate` (default: 0, means all)
344-
per_page: 10
344+
per_page: 5
345345

346346
# The permalink structure for the paginated pages (this can be any level deep)
347347
permalink: '/page/:num/' # Pages are index.html inside this folder (default)

โ€Žassets/js/adsense_in_article.jsโ€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
// blog-post ๋‚ด์— AdSense in article ์ฝ”๋“œ ์‚ฝ์ž….
44
function insertAdInRandomLocation() {
55
var adCode =
6-
`
7-
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1101850893094860"
6+
`<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1101850893094860"
87
crossorigin="anonymous"></script>
98
<ins class="adsbygoogle"
109
style="display:block; text-align:center;"

โ€Žassets/js/adsense_in_feed.jsโ€Ž

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Minjun 2023
22

3-
// blog-post ๋‚ด์— AdSense in feed ์ฝ”๋“œ ์‚ฝ์ž….
3+
// posts-list ๋งˆ์ง€๋ง‰์— AdSense ์‚ฝ์ž…
44
function insertAdInRandomLocation() {
5-
var elements = document.querySelectorAll('.post-preview');
6-
var randomIndex = Math.floor(Math.random() * elements.length);
7-
var randomElement = elements[randomIndex];
5+
var element = document.querySelector('.posts-list');
6+
// var randomIndex = Math.floor(Math.random() * elements.length);
7+
// var randomElement = elements[randomIndex];
88

99
let adCode =
1010
`<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1101850893094860"
@@ -19,8 +19,9 @@ function insertAdInRandomLocation() {
1919
<script>
2020
(adsbygoogle = window.adsbygoogle || []).push({})
2121
</script>`
22+
2223

23-
randomElement.insertAdjacentHTML('afterend', adCode);
24+
element.insertAdjacentHTML('beforeend', adCode);
2425
}
2526

2627
document.addEventListener("DOMContentLoaded", insertAdInRandomLocation);

0 commit comments

Comments
ย (0)