preloading

This commit is contained in:
cupcakearmy 2019-09-29 18:16:01 +02:00
parent 179d718a39
commit 80f048de3a
6 changed files with 48 additions and 27 deletions

View File

@ -8,22 +8,22 @@ steps:
commands:
- node -v
- pnpm --shamefully-flatten i
- pnpm run build:prod
#
#
# - name: deploy
# image: cupcakearmy/drone-deploy
# pull: always
# environment:
# PLUGIN_KEY:
# from_secret: ssh_key
# settings:
# host: srv-0.nicco.io
# user: root
# port: 1312
# target: /srv/web/blog
# sources:
# - ./liquet
# when:
# event: push
# branch: master
- pnpm run build
- name: deploy
image: cupcakearmy/drone-deploy
pull: always
environment:
PLUGIN_KEY:
from_secret: ssh_key
settings:
host: srv-0.nicco.io
user: root
port: 1312
target: /srv/web/blog
sources:
- ./liquet
when:
event: push
branch: master

View File

@ -5,6 +5,7 @@
"build": "parcel build --no-source-maps -d liquet/dist ./src/js/index.js ./src/styles/index.styl"
},
"dependencies": {
"@swup/preload-plugin": "^1.0.3",
"jquery": "^3.4.1",
"swup": "^2.0.7"
},

View File

@ -1,2 +1,11 @@
import './lights'
import './lazy'
import lights from './lights'
import lazy from './lazy'
import swup from './swup'
document.addEventListener('DOMContentLoaded', () => {
lights()
lazy()
swup(()=> {
lazy()
})
})

View File

@ -1,6 +1,6 @@
import jQuery from 'jquery'
import $ from 'jquery'
jQuery(($) => {
export default () => {
const bottomOffset = 300
const app = document.getElementById('app')
let loading = false
@ -35,4 +35,4 @@ jQuery(($) => {
// Check initial page if they need loading
load.bind(app)()
})
}

View File

@ -1,4 +1,4 @@
;((window) => {
export default () => {
// Lights
const key = 'nicco.io:blog:lights'
const CSS = 'body, .wp-block-image img, .thumbnail img {filter: invert(1);} '
@ -27,4 +27,4 @@
toFocus.tabIndex = '1'
toFocus.focus({preventScroll: true})
})
})(window)
}

11
src/js/swup.js Normal file
View File

@ -0,0 +1,11 @@
import Swup from 'swup'
import SwupPreloadPlugin from '@swup/preload-plugin';
export default (fn) => {
const swup = new Swup({
plugins: [new SwupPreloadPlugin()],
containers: ['#app']
})
swup.on('contentReplaced', fn)
}