![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
add-to-calendar-button
Advanced tools
A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.
A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.
This is for everybody, who wants to include a button at his/her website or app, which enables users to easily add a specific event to their calendars. It's main goal is to keep this process as easy as possible. Simply define your button configuration via JSON and everything else is automatically generated by the script. It is for this simple use case. No strings attached.
While building a personal wedding page, I was confronted with the task to include a button, where invited people could save the event to their calendars. I did not want to build this from scratch (first) and therefore started the usual web research. Unfortunately, all I found where some extremely outdated code snippets, which did not really fit all the modern systems and calendar tools. Beside that, there was only the solution by AddEvent.com - all over the place. I was looking at CodePen and all I found where thousands of pens, which basically only included the AddEvent tool. The problems with AddEvent.com:
See jekuer.github.io/add-to-calendar-button for a live demo.
<link rel="stylesheet" href="./assets/css/atcb.min.css">
), the js into the footer (<script src="./assets/js/atcb.min.js" defer></script>
). You can also combine them with other files, if you want to.npm install add-to-calendar-button
.import { atcb_init } from 'add-to-calendar-button';
.ngAfterViewInit()
with atcb_init();
(mind that, depending on your app, other hooks might be better);document.addEventListener('DOMContentLoaded', atcb_init, false);
or using hooks in a functional component like useEffect(() => atcb_init());
@import 'add-to-calendar-button/assets/css/atcb.min'
;A button can be easily created by placing a respective placeholder, wherever you want the button to appear.
(The style="display:none;"
theoretically is not necessary, but should be used for better compatibility.)
<div class="atcb" style="display:none;">
(...)
</div>
Within this placeholder, you can easily configure the button, by placing a respective JSON structure.
Mind that with Angular, you might need to escape the { with {{ '{' }}
and } with {{ '}' }}
; with React it would be { '{' }
and { '}' }
.
<div class="atcb" style="display:none;">
{
"name":"Add the title of your event",
"startDate":"2022-02-21",
"endDate":"2022-03-24",
"options":[
"Google"
]
}
</div>
<div class="atcb" style="display:none;">
{
"name":"Add the title of your event",
"description":"A nice description does not hurt",
"startDate":"2022-02-21",
"endDate":"2022-03-24",
"startTime":"10:13",
"endTime":"17:57",
"location":"Somewhere over the rainbow",
"label":"Add to Calendar",
"options":[
"Apple",
"Google",
"iCal",
"Microsoft365",
"MicrosoftTeams",
"Outlook.com",
"Yahoo"
],
"timeZone":"Europe/Berlin",
"timeZoneOffset":"+01:00",
"trigger":"click",
"iCalFileName":"Reminder-Event"
}
</div>
You can save on the style="display:none;"
, but mind that you should not use dynamic dates (e.g. "today" or "+1") here!
You can use startTime and endTime in the event block, but it is recommended to rather add it to startDate and endDate with "T" as delimiter here.
<div class="atcb">
<script type="application/ld+json">
{
"event": {
"@context":"https://schema.org",
"@type":"Event",
"name":"Add the title of your event",
"description":"A nice description does not hurt",
"startDate":"2022-02-21T10:13",
"endDate":"2022-03-24T17:57",
"location":"Somewhere over the rainbow"
},
"label":"Add to Calendar",
"options":[
"Apple",
"Google",
"iCal",
"Microsoft365",
"MicrosoftTeams",
"Outlook.com",
"Yahoo"
],
"timeZone":"Europe/Berlin",
"timeZoneOffset":"+01:00",
"trigger":"click",
"iCalFileName":"Reminder-Event"
}
</script>
</div>
A simpler method uses JSON.stringify()
where you define your config in an external file or variable and then
convert it to a string to be passed into the div.
const AddToCalendar = () => {
useEffect(() => atcb_init());
const event = { /* Event data */}
return (
<div className='atcb'>
<script type="application/ld+json">
{JSON.stringify(event)}
</script>
</div>
);
}
[url]https://....[/url]
makes it clickable.\n
or <br>
.Anyone is welcome to contribute, but mind the guidelines:
IMPORTANT NOTE: Run npm install
and npm run build
to create the minified js and css file, its sourcemap files as well as the npm_dist/ folder and content!
The code is available under the MIT license (with “Commons Clause” License Condition v1.0).
FAQs
A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.
The npm package add-to-calendar-button receives a total of 32,985 weekly downloads. As such, add-to-calendar-button popularity was classified as popular.
We found that add-to-calendar-button demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.