mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 13:44:15 +00:00
fix(pwa): site baseurl not passed to app.js (#1955)
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
import { pwa, baseurl } from '../../_config.yml';
|
||||
import Toast from 'bootstrap/js/src/toast';
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
if (pwa.enabled) {
|
||||
const swUrl = `${baseurl}/sw.min.js`;
|
||||
// Get Jekyll config from URL parameters
|
||||
const src = new URL(document.currentScript.src);
|
||||
const register = src.searchParams.get('register');
|
||||
const baseUrl = src.searchParams.get('baseurl');
|
||||
|
||||
if (register) {
|
||||
const swUrl = `${baseUrl}/sw.min.js`;
|
||||
const notification = document.getElementById('notification');
|
||||
const btnRefresh = notification.querySelector('.toast-body>button');
|
||||
const popupWindow = Toast.getOrCreateInstance(notification);
|
||||
|
||||
navigator.serviceWorker.register(swUrl).then((registration) => {
|
||||
// In case the user ignores the notification
|
||||
// Restore the update window that was last manually closed by the user
|
||||
if (registration.waiting) {
|
||||
popupWindow.show();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { baseurl } from '../../_config.yml';
|
||||
|
||||
importScripts(`${baseurl}/assets/js/data/swconf.js`);
|
||||
importScripts('./assets/js/data/swconf.js');
|
||||
|
||||
const purge = swconf.purge;
|
||||
const interceptor = swconf.interceptor;
|
||||
|
||||
Reference in New Issue
Block a user