Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #994 from Shinsina/additional-gtm-context
Browse files Browse the repository at this point in the history
Add `emailSchedules` and `magazineSchedules` to GTM content context
  • Loading branch information
B77Mills authored Oct 29, 2024
2 parents 26e6bad + 05b79cb commit 6b7480f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/marko-web-gtm/components/context/content.marko
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ fragment ContentContextFragment on Content {
name
}
}
emailSchedules {
id
deploymentDate
newsletter {
id
name
}
}
magazineSchedules {
id
issue {
id
name
mailDate(input: {format:"MM/DD/YYYY"})
}
}
}
`;

Expand Down
11 changes: 11 additions & 0 deletions packages/marko-web-gtm/context/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ module.exports = ({ obj, req }) => {
id: s.id,
name: s.name,
}));
const emailSchedules = getAsArray(content, 'emailSchedules')
.map((schedule) => ({
name: schedule.newsletter.name,
deploymentDate: schedule.deploymentDate,
}))
.sort((a, b) => a.deploymentDate - b.deploymentDate);
const magazineSchedules = getAsArray(content, 'magazineSchedules')
.map(({ issue: i }) => ({ name: i.name, mailDate: i.mailDate }))
.sort((a, b) => new Date(a.mailDate) - new Date(b.mailDate));
return {
page_type: 'content',
canonical_path: get(content, 'siteContext.path'),
Expand Down Expand Up @@ -59,5 +68,7 @@ module.exports = ({ obj, req }) => {
taxonomy,
authors,
schedules,
emailSchedules,
magazineSchedules,
};
};

0 comments on commit 6b7480f

Please sign in to comment.