-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying fix share-target not included in build
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Handling Share...</title> | ||
</head> | ||
<body> | ||
<p>Handling shared content...</p> | ||
<script src="share-target.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This function will be called when the PWA receives a share | ||
function handleShareTarget() { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const sharedUrl = urlParams.get('url') || urlParams.get('text'); | ||
|
||
if (sharedUrl) { | ||
// Redirect to the main page with the shared URL as a parameter | ||
window.location.href = `index.html?url=${encodeURIComponent(sharedUrl)}`; | ||
} else { | ||
// If no URL is shared, just go to the main page | ||
window.location.href = 'index.html'; | ||
} | ||
} | ||
|
||
// Call the function when the page loads | ||
handleShareTarget(); |