Skip to content

Commit

Permalink
Merge pull request #11 from reatlat/bugfix-crypt-not-defined
Browse files Browse the repository at this point in the history
Fix #10 Crypt is not defined in older versions of node
  • Loading branch information
zapalblizh authored May 15, 2024
2 parents 05d71ed + f689705 commit 8370c52
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
/* global hbspt */
module.exports = (eleventyConfig, options = {}) => {

const randomUUID = () => {

if (typeof crypto !== 'undefined') {
return crypto.randomUUID();
}

return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}

const hsScripts = {
forms: {
id: crypto.randomUUID(),
id: randomUUID(),
src: "https://js.hsforms.net/forms/embed/v2.js"
},
meetings: {
id: crypto.randomUUID(),
id: randomUUID(),
src: "https://static.hsappstatic.net/MeetingsEmbed/ex/MeetingsEmbedCode.js"
}
};
Expand Down Expand Up @@ -170,7 +184,7 @@ module.exports = (eleventyConfig, options = {}) => {
);
}

const uuid = crypto.randomUUID();
const uuid = randomUUID();

let hubspotFormCode = ``;

Expand Down

0 comments on commit 8370c52

Please sign in to comment.