Added affiliate parameters to scene URL.

This commit is contained in:
2024-06-22 22:51:57 +02:00
parent c2edf72081
commit 9ce9cfbb0c
8 changed files with 97 additions and 13 deletions

View File

@@ -2,10 +2,13 @@
<div class="page">
<div class="header">
<a
:href="entity.url"
:href="entityUrl"
target="_blank"
rel="noopener"
class="link link-child"
:data-umami-event="entity.affiliate ? 'entity-click-aff' : 'entity-click'"
:data-umami-event-aff-id="entity.affiliate?.id"
:data-umami-event-entity="entity.slug"
>
<template v-if="entity.hasLogo">
<img
@@ -113,6 +116,23 @@ const children = ref(null);
const expanded = ref(false);
const scrollable = computed(() => children.value?.scrollWidth > children.value?.clientWidth);
const entityUrl = (() => {
if (!entity.url) {
return null;
}
if (!entity.affiliate?.parameters) {
return entity.url;
}
const newParams = new URLSearchParams({
...Object.fromEntries(new URL(entity.url).searchParams),
...Object.fromEntries(new URLSearchParams(entity.affiliate.parameters)),
});
return `${entity.url}?${newParams}`;
})();
</script>
<style scoped>