chore: clarify with comment

This commit is contained in:
Arvid Norlin
2024-02-15 14:43:17 +01:00
parent b7c439fc6b
commit 4beb8da0b9

View File

@@ -15,13 +15,22 @@ function createPageObject(trackingData: TrackingData) {
.split("/")
.filter((v: string) => v)
// Better to get lang from useParams() instead?? ⬆️
function getSiteSections(segments: string[]) {
const sitesections: { [key: string]: string } = {}
// Adobe expects the properties sitesection1 - sitessection6, hence the for-loop below
/*
Adobe expects the properties sitesection1 - sitessection6, hence the for-loop below
The segments ['explore-scandic', 'wifi'] should result in:
{
sitesection1: "explore-scandic",
sitesection2: "explore-scandic|wifi",
sitesection3: "explore-scandic|wifi|",
sitesection4: "explore-scandic|wifi||",
sitesection5: "explore-scandic|wifi|||",
sitesection6: "explore-scandic|wifi||||",
}
*/
for (let i = 0; i < 6; i++) {
const key = "value" + (i + 1)
const key = "sitesection" + (i + 1)
sitesections[key] = segments.slice(0, i + 1).join("|")
if (i > 0 && !segments[i]) {
sitesections[key] = sitesections[key].concat(