Skip to content

Commit

Permalink
js changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-rajneeshkumar committed May 20, 2024
1 parent 5bf35fa commit 3b31b1c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ const AUDIENCES = {
desktop: () => window.innerWidth >= 600,
// define your custom audiences here as needed
};
export function getAllMetadata(scope) {
return [...document.head.querySelectorAll(`meta[property^="${scope}:"],meta[name^="${scope}-"]`)]
.reduce((res, meta) => {
const id = toClassName(meta.name
? meta.name.substring(scope.length + 1)
: meta.getAttribute('property').split(':')[1]);
res[id] = meta.getAttribute('content');
return res;
}, {});
}

window.hlx.plugins.add('experimentation', {
condition: () => getMetadata('experiment')
Expand Down

0 comments on commit 3b31b1c

Please sign in to comment.