diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 108fffbc0..00c1d92ba 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -22,25 +22,22 @@ window.VERCEL_ANALYTICS_ID = import.meta.env.VERCEL_ANALYTICS_ID?.toString() ?? false; } + // Format source array to count source occurrences let format = (arr) => { - const counts = {}; // Object to store the counts + const counts = {}; - // Loop through each item in the array arr.forEach((item) => { - // Increment the count for each key in the object - counts[item] = (counts[item] || 0) + 1; + const key = item.split(';')[0]; + counts[key] = (counts[key] || 0) + 1; }); - - // Convert counts object into the required string format array - const formattedArray = Object.entries(counts).map(([key, value]) => `${key},${value}`); - - return formattedArray; + return Object.entries(counts).map(([key, count]) => `${key};${count}`); }; onMount(async () => { // handle sources if (browser) { const source = Cookies.get('source'); + console.log(source); let sources = source ? decodeURIComponent(source).split(',') : []; console.log(sources);