diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts
index b36605c38..b3e9a5461 100644
--- a/packages/backend/src/server/api/endpoints/meta.ts
+++ b/packages/backend/src/server/api/endpoints/meta.ts
@@ -178,6 +178,7 @@ export const meta = {
place: {
type: 'string',
optional: false, nullable: false,
+ enum: ['square', 'horizontal', 'horizontal-big', 'vertical'],
},
ratio: {
type: 'number',
diff --git a/packages/frontend/src/components/MkDateSeparatedList.vue b/packages/frontend/src/components/MkDateSeparatedList.vue
index 0a71b689f..6ee65e2b6 100644
--- a/packages/frontend/src/components/MkDateSeparatedList.vue
+++ b/packages/frontend/src/components/MkDateSeparatedList.vue
@@ -95,7 +95,7 @@ export default defineComponent({
if (props.ad && item._shouldInsertAd_) {
return [h(MkAd, {
key: item.id + ':ad',
- prefer: ['horizontal', 'horizontal-big'],
+ prefer: [],
}), el];
} else {
return el;
diff --git a/packages/frontend/src/components/global/MkAd.vue b/packages/frontend/src/components/global/MkAd.vue
index 3ef5db3fe..97feb40db 100644
--- a/packages/frontend/src/components/global/MkAd.vue
+++ b/packages/frontend/src/components/global/MkAd.vue
@@ -63,24 +63,28 @@ const choseAd = (): Ad | null => {
ratio: 0,
} : ad);
- let ads = allAds.filter(ad => props.prefer.includes(ad.place));
+ const valuableAds = allAds.filter(ad => ad.ratio !== 0);
+ const lowPriorityAds = allAds.filter(ad => ad.ratio === 0);
- if (ads.length === 0) {
- ads = allAds.filter(ad => ad.place === 'square');
+ let ads: Ad[];
+ const preferredAds = valuableAds.filter(ad => props.prefer.includes(ad.place));
+ if (preferredAds.length !== 0) {
+ ads = preferredAds;
+ } else {
+ ads = lowPriorityAds.filter(ad => props.prefer.includes(ad.place));
}
- const lowPriorityAds = ads.filter(ad => ad.ratio === 0);
- ads = ads.filter(ad => ad.ratio !== 0);
-
if (ads.length === 0) {
- if (lowPriorityAds.length !== 0) {
- return lowPriorityAds[Math.floor(Math.random() * lowPriorityAds.length)];
+ const nonPreferredAds = valuableAds.filter(ad => !props.prefer.includes(ad.place));
+ if (nonPreferredAds.length !== 0) {
+ ads = nonPreferredAds;
} else {
- return null;
+ ads = lowPriorityAds.filter(ad => !props.prefer.includes(ad.place));
}
}
const totalFactor = ads.reduce((a, b) => a + b.ratio, 0);
+ if (totalFactor === 0) return ads[Math.floor(Math.random() * ads.length)];
const r = Math.random() * totalFactor;
let stackedFactor = 0;
@@ -148,7 +152,8 @@ function reduceFrequency(): void {
&.form_vertical {
> .link,
> .link > .img {
- max-width: min(100px, 100%);
+ max-width: min(300px, 100%);
+ max-height: 450px;
}
}
}
diff --git a/packages/frontend/src/pages/admin/ads.vue b/packages/frontend/src/pages/admin/ads.vue
index 5884ac74b..f911181c1 100644
--- a/packages/frontend/src/pages/admin/ads.vue
+++ b/packages/frontend/src/pages/admin/ads.vue
@@ -29,6 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
+