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 #1009 from parameter1/newsletter-stealth-link
Browse files Browse the repository at this point in the history
Add newsletter stealth link component
  • Loading branch information
brandonbk authored Nov 11, 2024
2 parents d3cfbcc + 3a4f477 commit d4ca028
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/marko-newsletters/components/marko.json
Original file line number Diff line number Diff line change
@@ -22,5 +22,8 @@
"@title": "string",
"@description": "string",
"@date": "object"
},
"<marko-newsletter-stealth-link>": {
"template": "./stealth-link.marko"
}
}
15 changes: 15 additions & 0 deletions packages/marko-newsletters/components/stealth-link.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { get } from "@parameter1/base-cms-object-path";
import defaultValue from "@parameter1/base-cms-marko-core/utils/default-value";
import moment from "moment";

$ const { newsletter, date } = input;

$ const newsletterSiteName = get(newsletter, "site.name") || "Homepage";
$ const linkText = defaultValue(input.linkText, newsletterSiteName);
$ const unixTimestamp = moment(date).unix();
$ const position = defaultValue(input.position, "top");
$ const linkUrl = `${newsletter.site.origin}/email-preview?newsletterId=${newsletter.id}&timestamp=${unixTimestamp}&position=${position}`;

<div name="divPreviewLink" style="display:none;height:0px;width:0px;overflow:hidden;visibility:hidden;mso-hide:all">
<a href=linkUrl>${linkText}</a>
</div>

0 comments on commit d4ca028

Please sign in to comment.