mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
merch internal banner
This commit is contained in:
parent
b20d73da34
commit
e7d1eceffb
@ -40,7 +40,7 @@
|
|||||||
import adPlaceholders from '../src/adPlaceholders.js';
|
import adPlaceholders from '../src/adPlaceholders.js';
|
||||||
import getAdsInternal from '../src/adsInternal.js';
|
import getAdsInternal from '../src/adsInternal.js';
|
||||||
import { mapState } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
import { randomItem } from '../src/helpers.ts';
|
import { randomItemWeighted } from '../src/helpers.ts';
|
||||||
|
|
||||||
const MOBILE_BREAKPOINT = 992;
|
const MOBILE_BREAKPOINT = 992;
|
||||||
|
|
||||||
@ -90,12 +90,12 @@ export default {
|
|||||||
(this.adsInternal[this.currentKey] || adPlaceholders[this.currentKey]);
|
(this.adsInternal[this.currentKey] || adPlaceholders[this.currentKey]);
|
||||||
},
|
},
|
||||||
adConfig() {
|
adConfig() {
|
||||||
if (!this.externalAdsEnabled && Math.random() < 0.5) {
|
if (!this.externalAdsEnabled && Math.random() < 0.3) {
|
||||||
return { active: false };
|
return { active: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.adConfigPossibilities.length
|
return this.adConfigPossibilities.length
|
||||||
? { active: true, ...randomItem(this.adConfigPossibilities) }
|
? { active: true, ...randomItemWeighted(this.adConfigPossibilities) }
|
||||||
: { active: false };
|
: { active: false };
|
||||||
},
|
},
|
||||||
adConfigPossibilities() {
|
adConfigPossibilities() {
|
||||||
@ -112,6 +112,7 @@ export default {
|
|||||||
if (this.externalAdsEnabled) {
|
if (this.externalAdsEnabled) {
|
||||||
const { slotId, adFormat, adLayout = null, responsive = false, video = false, sticky = false } = adPlaceholders[this.currentKey];
|
const { slotId, adFormat, adLayout = null, responsive = false, video = false, sticky = false } = adPlaceholders[this.currentKey];
|
||||||
possibilities.push({
|
possibilities.push({
|
||||||
|
chance: 1,
|
||||||
fuse: true,
|
fuse: true,
|
||||||
slotId,
|
slotId,
|
||||||
adFormat,
|
adFormat,
|
||||||
|
@ -74,6 +74,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<AdPlaceholder :phkey="['content-0', 'content-mobile-0']" />
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h3 class="mb-3">
|
<h3 class="mb-3">
|
||||||
<Icon v="users" />
|
<Icon v="users" />
|
||||||
|
@ -21,7 +21,7 @@ export const adsInternal = [
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
locale: 'pl',
|
locale: 'pl',
|
||||||
image: 'workshops-pl.png',
|
image: 'workshops-pl.png',
|
||||||
placeholders: ['content-1'],
|
placeholders: ['content-0'],
|
||||||
link: 'https://zaimki.pl/szkolenia',
|
link: 'https://zaimki.pl/szkolenia',
|
||||||
display: 'd-none d-md-block',
|
display: 'd-none d-md-block',
|
||||||
alt: 'Oferujemy szkolenia i warsztaty dla firm i organizacji',
|
alt: 'Oferujemy szkolenia i warsztaty dla firm i organizacji',
|
||||||
@ -30,7 +30,7 @@ export const adsInternal = [
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
locale: 'pl',
|
locale: 'pl',
|
||||||
image: 'workshops-pl-mobile.png',
|
image: 'workshops-pl-mobile.png',
|
||||||
placeholders: ['content-mobile-1'],
|
placeholders: ['content-mobile-0'],
|
||||||
link: 'https://zaimki.pl/szkolenia',
|
link: 'https://zaimki.pl/szkolenia',
|
||||||
display: 'd-block d-md-none',
|
display: 'd-block d-md-none',
|
||||||
alt: 'Oferujemy szkolenia i warsztaty dla firm i organizacji',
|
alt: 'Oferujemy szkolenia i warsztaty dla firm i organizacji',
|
||||||
@ -39,7 +39,7 @@ export const adsInternal = [
|
|||||||
// enabled: true,
|
// enabled: true,
|
||||||
// locale: 'en',
|
// locale: 'en',
|
||||||
// image: 'workshops-en.png',
|
// image: 'workshops-en.png',
|
||||||
// placeholders: ['content-1'],
|
// placeholders: ['content-0'],
|
||||||
// link: 'https://en.pronouns.page/workshops',
|
// link: 'https://en.pronouns.page/workshops',
|
||||||
// display: 'd-none d-md-block',
|
// display: 'd-none d-md-block',
|
||||||
// alt: 'We offer training and workshops for companies and organisations.',
|
// alt: 'We offer training and workshops for companies and organisations.',
|
||||||
@ -48,11 +48,28 @@ export const adsInternal = [
|
|||||||
// enabled: true,
|
// enabled: true,
|
||||||
// locale: 'en',
|
// locale: 'en',
|
||||||
// image: 'workshops-en-mobile.png',
|
// image: 'workshops-en-mobile.png',
|
||||||
// placeholders: ['content-mobile-1'],
|
// placeholders: ['content-mobile-0'],
|
||||||
// link: 'https://en.pronouns.page/workshops',
|
// link: 'https://en.pronouns.page/workshops',
|
||||||
// display: 'd-block d-md-none',
|
// display: 'd-block d-md-none',
|
||||||
// alt: 'We offer training and workshops for companies and organisations.',
|
// alt: 'We offer training and workshops for companies and organisations.',
|
||||||
// },
|
// },
|
||||||
|
{
|
||||||
|
enabled: true,
|
||||||
|
locale: 'en',
|
||||||
|
image: 'merch-1.png',
|
||||||
|
placeholders: ['content-0', 'content-mobile-0'],
|
||||||
|
link: 'https://shop.pronouns.page',
|
||||||
|
alt: 'Show off your pride and support the project – shop.pronouns.page',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
enabled: true,
|
||||||
|
locale: 'en',
|
||||||
|
image: 'merch-1.png',
|
||||||
|
placeholders: ['header'],
|
||||||
|
link: 'https://shop.pronouns.page',
|
||||||
|
alt: 'Show off your pride and support the project – shop.pronouns.page',
|
||||||
|
chance: 0.1,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default (locale) => {
|
export default (locale) => {
|
||||||
@ -66,7 +83,7 @@ export default (locale) => {
|
|||||||
if (!adsInternalPerPlaceholder.hasOwnProperty(placeholder)) {
|
if (!adsInternalPerPlaceholder.hasOwnProperty(placeholder)) {
|
||||||
adsInternalPerPlaceholder[placeholder] = [];
|
adsInternalPerPlaceholder[placeholder] = [];
|
||||||
}
|
}
|
||||||
adsInternalPerPlaceholder[placeholder].push(ad);
|
adsInternalPerPlaceholder[placeholder].push({chance: 0.25, ...ad});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,6 +232,24 @@ export const shuffle = <T>(array: T[]): T[] => {
|
|||||||
|
|
||||||
export const randomItem = <T>(array: T[]): T => array[Math.floor(Math.random() * array.length)];
|
export const randomItem = <T>(array: T[]): T => array[Math.floor(Math.random() * array.length)];
|
||||||
|
|
||||||
|
interface WeightedItem {
|
||||||
|
chance?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const randomItemWeighted = <T extends WeightedItem>(array: T[]): T => {
|
||||||
|
const totalChance = array.reduce((sum, obj) => sum + (obj.chance ?? 1), 0);
|
||||||
|
let randomChance = Math.random() * totalChance;
|
||||||
|
|
||||||
|
for (const el of array) {
|
||||||
|
randomChance -= el.chance ?? 1;
|
||||||
|
if (randomChance <= 0) {
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array[array.length - 1];
|
||||||
|
}
|
||||||
|
|
||||||
export const randomNumber = (min: number, max: number): number => Math.floor(Math.random() * (max - min + 1)) + min;
|
export const randomNumber = (min: number, max: number): number => Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
|
||||||
|
|
||||||
|
BIN
static/banners/merch-1.png
Normal file
BIN
static/banners/merch-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 120 KiB |
Loading…
x
Reference in New Issue
Block a user