Skip to content

Commit 2056e12

Browse files
committed
✨ ajout de l'affichage du lien d'affilication digital ocean
1 parent 40ee397 commit 2056e12

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

resources/css/base.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ input {
99
.hide-scroll::-webkit-scrollbar { display: none; }
1010

1111
[x-cloak] {display: none; }
12+
13+
.affiliate img {
14+
margin-bottom: 0 !important;
15+
border-bottom-left-radius: 0;
16+
border-bottom-right-radius: 0;
17+
}

resources/js/components/Comments.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { findAllReplies, addReply, updateReply, deleteReply, likeReply } from '@
66
import { DefaultButton, PrimaryButton } from '@components/Button';
77
import { Field } from '@components/Form'
88
import { Markdown } from '@components/Markdown'
9-
import { ChatIcon, HeartIcon } from '@components/Icon'
9+
import { HeartIcon } from '@components/Icon'
1010
import { canManage, currentUser, isAuthenticated, getUserId } from '@helpers/auth'
1111
import { scrollTo } from '@helpers/animation'
1212
import { catchViolations } from '@helpers/api'

resources/js/elements/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import preactCustomElement from '@helpers/preact.js'
2-
import { Comments } from '@components/Comments.jsx'
3-
import { Confetti } from './Confetti.js'
4-
import { TimeAgo } from './TimeAgo.js'
5-
import { TimeCountdown } from './TimeCountdown.js'
2+
import { Comments } from '@components/Comments'
3+
import { Confetti } from './Confetti'
4+
import { TimeAgo } from './TimeAgo'
5+
import { TimeCountdown } from './TimeCountdown'
66

77
customElements.define('con-fetti', Confetti)
88
customElements.define('time-ago', TimeAgo)

resources/js/helpers.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import hljs from 'highlight.js';
2-
import Choices from 'choices.js';
1+
import hljs from 'highlight.js'
2+
import Choices from 'choices.js'
33

44
// Create a multiselect element.
55
window.choices = (element) => {
66
return new Choices(element, { maxItemCount: 3, removeItemButton: true });
7-
};
7+
}
88

99
// Syntax highlight code blocks.
1010
window.highlightCode = (element) => {
1111
element.querySelectorAll('pre code').forEach((block) => {
1212
hljs.highlightBlock(block);
13-
});
14-
};
13+
})
14+
}
1515

1616
// Create Capitalize string
17-
window.capitalize = (string) => string.replace(/^\w/, (c) => c.toUpperCase());
17+
window.capitalize = (string) => string.replace(/^\w/, (c) => c.toUpperCase())
1818

1919
// Create a snake case string
20-
window.snakeCase = (string) => string && string.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(s => s.toLowerCase()).join('_');
20+
window.snakeCase = (string) => string && string.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(s => s.toLowerCase()).join('_')
2121

2222
// Share a content to social Media
2323
const share = function () {
@@ -65,3 +65,31 @@ const share = function () {
6565
}
6666

6767
share()
68+
69+
// Get all p tag of a content and get the 8th to add a link element with affiliate link
70+
const addAffiliateLink = function () {
71+
let articleContent = document.getElementById('content')
72+
73+
if (! articleContent) {
74+
return;
75+
}
76+
77+
let pTags = document.getElementById('content').querySelectorAll('p')
78+
let i = 0
79+
pTags.forEach((p) => {
80+
if (i === 7) {
81+
let a = document.createElement('a')
82+
a.setAttribute('href', 'https://www.digitalocean.com/?refcode=d6dca1691fb4&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge')
83+
a.setAttribute('target', '_blank')
84+
a.classList.add('relative', 'affiliate', 'block', 'w-full', 'mb-6', 'overflow-hidden', 'rounded-lg', 'cursor-pointer')
85+
a.innerHTML = `
86+
<img src="/images/affiliate-link.jpg" class="w-full rounded-t-lg" alt="Affiliate link" />
87+
<span class="block w-full h-auto px-3 py-2 font-bold text-center text-white uppercase text-xs bg-gradient-to-r from-green-500 via-indigo-600 to-blue-500">Obtenez le code gratuit en créant votre serveur 🚀</span>
88+
`
89+
p.parentNode.insertBefore(a, p.nextSibling)
90+
}
91+
i++
92+
})
93+
}
94+
95+
addAffiliateLink()

0 commit comments

Comments
 (0)