Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion to-do-notifications/scripts/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ window.onload = () => {
// Create a notification with the given title
function createNotification(title) {
// Create and show the notification
const img = '/to-do-notifications/img/icon-128.png';
const img = '/dom-examples/to-do-notifications/img/icon-128.png';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good for the GitHub version, but will break on local ones, should we do something like:

const basePath = window.origin.includes("github.io") 
  ? "/dom-examples" 
  : "";

const img = `${basePath}/to-do-notifications/img/icon-128.png`;

If it's on GitHub, add the repo to the base path, otherwise use an empty string?

const text = `HEY! Your task "${title}" is now overdue.`;
const notification = new Notification('To do list', { body: text, icon: img });

Expand Down