-
Notifications
You must be signed in to change notification settings - Fork 0
/
holiday-card.js
40 lines (37 loc) · 1.57 KB
/
holiday-card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import PinterestEmbed from './pinterest-embed';
import TweetButton from './twitter-button';
function checkForVowel(input) {
const vowels = ['a', 'e', 'i', 'o', 'u'];
if (vowels.includes(input.charAt(0).toLowerCase())) {
return 'an';
}
return 'a';
}
const HolidayCard = ({ holidayObj }) => {
const holidayName = ('' + holidayObj.scope + ' ' + holidayObj.food + ' ' + holidayObj.unit).trim();
// let intro;
// if (holidayObj.duration > 1) {
// intro = 'This ' + holidayObj.unit.toLowerCase() + ' is ' + holidayName + '!';
// }
// else {
// intro = 'Today is ' + holidayName + '!';
// }
let tweetMsg = 'I\'m celebrating ' + holidayObj.scope + ' ' + holidayObj.food + ' ' + holidayObj.unit + '! Find out what food holiday it is today!';
return (
<div class="holiday-card">
<div>
<h2>
Happy {holidayName}!
</h2>
</div>
<p><a target="_blank" rel="noopener noreferrer" href={'https://www.google.com/search?q=' + holidayObj.food.replace(/\W/g, '+').toLowerCase() + '+recipe'}>Get {checkForVowel(holidayObj.food)} {holidayObj.food.toLowerCase()} recipe</a>, whip it up and then tell the world how much you love it. Post it with the hashtag <a target="_blank" rel="noopener noreferrer" href="https://www.instagram.com/explore/tags/nationalfoodtoday/">#nationalfoodtoday</a> on Instagram, Twitter, or Pinterest for a chance to be featured!</p>
{holidayObj.pinterest_embed &&
<PinterestEmbed location={holidayObj.pinterest_embed} size="medium" />
}
<div align="right">
<TweetButton msg={tweetMsg} />
</div>
</div>
);
};
export default HolidayCard;