Squashed commit of the following:

commit 787b84159c894cb38ea9eb1423069884f8b56bc4
Author: ChrisDill <chris.rj.dill@gmail.com>
Date:   Sat Jul 24 16:57:16 2021 +0100

    Test footer fix for smaller resolutions

commit bc8cba413d12250d76118ce31668a6dd4e8eebbd
Author: ChrisDill <chris.rj.dill@gmail.com>
Date:   Wed Jul 21 18:53:05 2021 +0100

    Add jsconfig.json and update error/layout prefix

commit 03d1cfced8b095ff79173a25ac2612aaa7f895aa
Author: ChrisDill <chris.rj.dill@gmail.com>
Date:   Wed Jul 21 18:06:45 2021 +0100

    Test sveltekit fixes to get static adapter to work

commit 6f4c28b0ead9d758fbb649d13188da38a6dfb00f
Author: ChrisDill <chris.rj.dill@gmail.com>
Date:   Wed Dec 16 10:25:42 2020 +0000

    Initial sveltekit test
    - New branch for testing out sveltekit. It is not yet 1.0 so this is for experimental purposes.
This commit is contained in:
Chris Dill 2021-07-26 12:22:47 +01:00
parent 0d5b3c6ecc
commit c35c09af53
24 changed files with 438 additions and 3104 deletions

4
.gitignore vendored
View File

@ -1,2 +1,4 @@
__sapper__
node_modules
node_modules
.svelte-kit
build

View File

@ -1,4 +0,0 @@
{
"baseUrl": "http://localhost:3000",
"video": false
}

View File

@ -1,5 +0,0 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View File

@ -1,19 +0,0 @@
describe('Sapper template app', () => {
beforeEach(() => {
cy.visit('/')
});
it('has the correct <h1>', () => {
cy.contains('h1', 'Great success!')
});
it('navigates to /about', () => {
cy.get('nav a').contains('about').click();
cy.url().should('include', '/about');
});
it('navigates to /blog', () => {
cy.get('nav a').contains('blog').click();
cy.url().should('include', '/blog');
});
});

View File

@ -1,17 +0,0 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

View File

@ -1,25 +0,0 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

View File

@ -1,20 +0,0 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

10
jsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"$lib": ["src/lib"],
"$lib/*": ["src/lib/*"]
}
},
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
}

2695
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +1,15 @@
{
"name": "Quartznet",
"description": "Quartznet website",
"version": "0.0.1",
"scripts": {
"dev": "sapper dev",
"build": "sapper build --legacy",
"export": "sapper export --legacy",
"start": "node __sapper__/build",
"cy:run": "cypress run",
"cy:open": "cypress open",
"test": "run-p --race dev cy:run"
},
"dependencies": {
"compression": "^1.7.4",
"polka": "next"
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"preview": "svelte-kit preview"
},
"devDependencies": {
"npm-run-all": "^4.1.5",
"sapper": "^0.28.0",
"svelte": "^3.24.1",
"@babel/core": "^7.11.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.11.0",
"@babel/preset-env": "^7.11.0",
"@babel/runtime": "^7.11.2",
"@rollup/plugin-babel": "^5.2.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-replace": "^2.3.3",
"rollup": "^2.26.4",
"rollup-plugin-svelte": "^5.2.3",
"rollup-plugin-terser": "^7.0.0",
"sirv": "^1.0.6"
}
"@sveltejs/adapter-static": "^1.0.0-next.13",
"@sveltejs/kit": "next",
"svelte": "^3.34.0"
},
"type": "module"
}

View File

@ -1,105 +0,0 @@
import resolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import commonjs from '@rollup/plugin-commonjs';
import svelte from 'rollup-plugin-svelte';
import babel from '@rollup/plugin-babel';
import {terser} from 'rollup-plugin-terser';
import config from 'sapper/config/rollup.js';
import pkg from './package.json';
const mode = process.env.NODE_ENV;
const dev = mode === 'development';
const legacy = !!process.env.SAPPER_LEGACY_BUILD;
const onwarn = (warning, onwarn) =>
(warning.code === 'MISSING_EXPORT' && /'preload'/.test(warning.message)) ||
(warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) ||
onwarn(warning);
export default {
client: {
input: config.client.input(),
output: config.client.output(),
plugins: [
replace({
'process.browser': true,
'process.env.NODE_ENV': JSON.stringify(mode)
}),
svelte({
dev,
hydratable: true,
emitCss: true
}),
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
legacy && babel({
extensions: ['.js', '.mjs', '.html', '.svelte'],
babelHelpers: 'runtime',
exclude: ['node_modules/@babel/**'],
presets: [
['@babel/preset-env', {
targets: '> 0.25%, not dead'
}]
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
['@babel/plugin-transform-runtime', {
useESModules: true
}]
]
}),
!dev && terser({
module: true
})
],
preserveEntrySignatures: false,
onwarn,
},
server: {
input: config.server.input(),
output: config.server.output(),
plugins: [
replace({
'process.browser': false,
'process.env.NODE_ENV': JSON.stringify(mode)
}),
svelte({
generate: 'ssr',
hydratable: true,
dev
}),
resolve({
dedupe: ['svelte']
}),
commonjs()
],
external: Object.keys(pkg.dependencies).concat(require('module').builtinModules),
preserveEntrySignatures: 'strict',
onwarn,
},
serviceworker: {
input: config.serviceworker.input(),
output: config.serviceworker.output(),
plugins: [
resolve(),
replace({
'process.browser': true,
'process.env.NODE_ENV': JSON.stringify(mode)
}),
commonjs(),
!dev && terser()
],
preserveEntrySignatures: false,
onwarn,
}
};

View File

@ -1,125 +0,0 @@
// @ts-check
/** This script modifies the project to support TS code in .svelte files like:
<script lang="ts">
export let name: string;
</script>
As well as validating the code for CI.
*/
/** To work on this script:
rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
*/
const fs = require("fs")
const path = require("path")
const {argv} = require("process")
const projectRoot = argv[2] || path.join(__dirname, "..")
// Add deps to pkg.json
const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"))
packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
"svelte-check": "^1.0.0",
"svelte-preprocess": "^4.0.0",
"@rollup/plugin-typescript": "^4.0.0",
"typescript": "^3.9.3",
"tslib": "^2.0.0",
"@tsconfig/svelte": "^1.0.0"
})
// Add script for checking
packageJSON.scripts = Object.assign(packageJSON.scripts, {
"validate": "svelte-check"
})
// Write the package JSON
fs.writeFileSync(path.join(projectRoot, "package.json"), JSON.stringify(packageJSON, null, " "))
// mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
const beforeMainJSPath = path.join(projectRoot, "src", "main.js")
const afterMainTSPath = path.join(projectRoot, "src", "main.ts")
fs.renameSync(beforeMainJSPath, afterMainTSPath)
// Switch the app.svelte file to use TS
const appSveltePath = path.join(projectRoot, "src", "index.svelte")
let appFile = fs.readFileSync(appSveltePath, "utf8")
appFile = appFile.replace("<script>", '<script lang="ts">')
appFile = appFile.replace("export let name;", 'export let name: string;')
fs.writeFileSync(appSveltePath, appFile)
// Edit rollup config
const rollupConfigPath = path.join(projectRoot, "rollup.config.js")
let rollupConfig = fs.readFileSync(rollupConfigPath, "utf8")
// Edit imports
rollupConfig = rollupConfig.replace(`'rollup-plugin-terser';`, `'rollup-plugin-terser';
import sveltePreprocess from 'svelte-preprocess';
import typescript from '@rollup/plugin-typescript';`)
// Replace name of entry point
rollupConfig = rollupConfig.replace(`'src/main.js'`, `'src/main.ts'`)
// Add preprocess to the svelte config, this is tricky because there's no easy signifier.
// Instead we look for `css:` then the next `}` and add the preprocessor to that
let foundCSS = false
let match
// https://regex101.com/r/OtNjwo/1
const configEditor = new RegExp(/css:.|\n*}/gmi)
while ((match = configEditor.exec(rollupConfig)) != null) {
if (foundCSS) {
const endOfCSSIndex = match.index + 1
rollupConfig = rollupConfig.slice(0, endOfCSSIndex) + ",\n preprocess: sveltePreprocess()," + rollupConfig.slice(endOfCSSIndex);
break
}
if (match[0].includes("css:")) foundCSS = true
}
// Add TypeScript
rollupConfig = rollupConfig.replace("commonjs(),", 'commonjs(),\n\t\ttypescript({ sourceMap: !production }),')
fs.writeFileSync(rollupConfigPath, rollupConfig)
// Add TSConfig
const tsconfig = `{
"extends": "@tsconfig/svelte/tsconfig.json",
"include": ["src/**/*"],
"exclude": ["node_modules/*", "__sapper__/*", "public/*"],
}`
const tsconfigPath = path.join(projectRoot, "tsconfig.json")
fs.writeFileSync(tsconfigPath, tsconfig)
// Delete this script, but not during testing
if (!argv[2]) {
// Remove the script
fs.unlinkSync(path.join(__filename))
// Check for Mac's DS_store file, and if it's the only one left remove it
const remainingFiles = fs.readdirSync(path.join(__dirname))
if (remainingFiles.length === 1 && remainingFiles[0] === '.DS_store') {
fs.unlinkSync(path.join(__dirname, '.DS_store'))
}
// Check if the scripts folder is empty
if (fs.readdirSync(path.join(__dirname)).length === 0) {
// Remove the scripts folder
fs.rmdirSync(path.join(__dirname))
}
}
// Adds the extension recommendation
fs.mkdirSync(path.join(projectRoot, ".vscode"))
fs.writeFileSync(path.join(projectRoot, ".vscode", "extensions.json"), `{
"recommendations": ["svelte.svelte-vscode"]
}
`)
console.log("Converted to TypeScript.")
if (fs.existsSync(path.join(projectRoot, "node_modules"))) {
console.log("\nYou will need to re-run your dependency manager to get started.")
}

View File

@ -1,316 +0,0 @@
<script>
import {onMount} from 'svelte'
var view = document.getElementsByTagName('pre')[0];
var appa = ` .,-:;//;:=,
. :H@@@MM@M#H/.,+%;,
,/X+ +M@@M@MM%=,-%HMMM@X/,
-+@MM; $M@@MH+-,;XMMMM@MMMM@+-
;@M@@M- XM@X;. -+XXXXXHHH@M@M#@/.
,%MM@@MH ,@%= .---=-=:=,.
-@#@@@MX ., -%HX$$%%%+;
=-./@M@M$ .;@MMMM@MM:
X@/ -$MM/ .+MM@@@M$
,@M@H: :@: . -X#@@@@-
,@@@MMX, . /H- ;@M@M=
.H@@@@M@+, %MM+..%#$.
/MMMM@MMH/. XM@MH; -;
/%+%$XHH@$= , .H@@@@MX,
.=--------. -%H.,@@@@@MX,
.%MM@@@HHHXX$$$%+- .:$MMX -M@@MM%.
=XMMM@MM@MM#H;,-+HMM@M+ /MMMX=
=%@M@M#@$-.=$@MM@@@M; %M%=
,:+$+-,/H#MMMMMMM@- -,
=++%%%%+/:-.`;
var nuke = ` =+$HM####@H%;,
/H###############M$,
,@################+
.H##############+
X############/
$##########/
%########/
/X/;;+X/
-XHHX-
,######,
#############X .M####M. X#############
##############- -//- -##############
X##############%, ,+##############X
-##############X X##############-
%############% %############%
%##########; ;##########%
;#######M= =M#######;
.+M###@, ,@###M+.
:XH. .HX:`;
var atom = ` =/;;/-
+: //
/; /;
-X H.
.//;;;:;;-, X= :+ .-;:=;:;%;.
M- ,=;;;#:, ,:#;;:=, ,@
:% :%.=/++++/=.$= %=
,%; %/:+/;,,/++:+/ ;+.
,+/. ,;@+, ,%H;, ,/+,
;+;;/= @. .H##X -X :///+;
;+=;;;.@, .XM@$. =X.//;=%/.
,;: :@%= =$H: .+%-
,%= %;-///==///-// =%,
;+ :%-;;;;;;;;-X- +:
@- .-;;;;M- =M/;;;-. -X
:;;::;;-. %- :+ ,-;;-;:==
,X H.
;/ %=
// +;
,////,`;
var heart = ` .,---.
,/XM#MMMX;,
-%##########M%,
-@######% $###@=
.,--, -H#######$ $###M:
,;$M###MMX; .;##########$;HM###X=
,/@###########H= ;################+
-+#############M/, %##############+
%M###############= /##############:
H################ .M#############;.
@###############M ,@###########M:.
X################, -$=X#######@:
/@##################%- +######$-
.;##################X .X#####+,
.;H################/ -X####+.
,;X##############, .MM/
,:+$H@M#######M#$- .$$=
.,-=;+$@###X: ;/=.
.,/X$; .::,
., ..`;
var fire = ` -$-
.H##H,
+######+
.+#########H.
-$############@.
=H###############@ -X:
.$##################: @#@-
,; .M###################; H###;
;@#: @###################@ ,#####:
-M###. M#################@. ;######H
M####- +###############$ =@#######X
H####$ -M###########+ :#########M,
/####X- =########% :M########@/.
,;%H@X; .$###X :##MM@%+;:-
..
-/;:-,. ,,-==+M########H
-##################@HX%%+%%$%%%+:,,
.-/H%%%+%%$H@###############M@+=:/+:
/XHX%:#####MH%= ,---:;;;;/&&XHM,:###$
$@#MX %+;- .`;
var tick = ` :X-
:X###
;@####@
;M######X
-@########$
.$##########@
=M############-
+##############$
.H############$=.
,/: ,M##########M;.
-+@###; =##########M;
=%M#######; :#########M/
-$M###########; :########/
,;X###########; =#######$.
;H#########+######M=
,+#############+
/M########@-
;M#####%
+####:
,$M-`;
var bang = ` .+
/M;
H#@: ;,
-###H- -@/
%####$. -; .%#X
M#####+;#H :M#M.
.. .+/;%#############-
-/%H%+;-, +##############/
.:$M###MH$%+############X ,--=;-
-/H#####################H+=.
.+#################X.
=%M####################H;.
/@###############+;;/%%;,
-%###################$
;H######################M=
,%#####MH$%;+#####M###-/@####%
:$H%+;=- -####X.,H# -+M##@-
. ,###; ; =$##+
.#H, :XH,
+ .;-`;
var mesa = ` .-;+$XHHHHHHX$+;-.
,;X@@X%/;=----=:/%X@@X/,
=$@@%=. .=+H@X:
-XMX: =XMX=
/@@: =H@+
%@X, .$@$
+@X. $@%
-@@, .@@=
%@% +@$
H@: :@H
H@: :HHHHHHHHHHHHHHHHHHX, =@H
%@% ;@M@@@@@@@@@@@@@@@@@H- +@$
=@@, :@@@@@@@@@@@@@@@@@@@@@= .@@:
+@X :@@@@@@@@@@@@@@@M@@@@@@:%@%
$@$, ;@@@@@@@@@@@@@@@@@M@@@@@@$.
+@@HHHHHHH@@@@@@@@@@@@@@@@@@@@@@@+
=X@@@@@@@@@@@@@@@@@@@@@@@@@@@@X=
:$@@@@@@@@@@@@@@@@@@@M@@@@$:
,;$@@@@@@@@@@@@@@@@@@X/-
.-;+$XXHHHHHX$+;-.`;
var cube = ` #+ @ # # M#@
. .X X.%##@;# # +@#######X. @H%
,==. ,######M+ -#####%M####M- #
:H##M%:=##+ .M##M,;#####/+#######% ,M#
.M########= =@#@.=#####M=M#######= X#
:@@MMM##M. -##M.,#######M#######. = M
@##..###:. .H####. @@ X,
############: ###,/####; /##= @#. M
,M## ;##,@#M;/M#M @# X#% X#
.%= ######M## ##.M#: ./#M ,M #M ,#$
##/ $## #+;#: #### ;#/ M M- @# :
#+ #M@MM###M-;M #:$#-##$H# .#X @ + $#. #
######/.: #%=# M#:MM./#.-# @#: H#
+,.= @###: /@ %#,@ ##@X #,-#@.##% .@#
#####+;/##/ @## @#,+ /#M . X,
;###M#@ M###H .#M- ,##M ;@@; ###
.M#M##H ;####X ,@#######M/ -M###$ -H
.M###% X####H .@@MM@; ;@#M@
H#M /@####/ ,++. / ==-,
,=/:, .+X@MMH@#H #####$=`;
var cake = ` ,:/+/-
/M/ .,-=;//;-
.:/= ;MH/, ,=/+%$XH@MM#@:
-$##@+$###@H@MMM#######H:. -/H#
.,H@H@ X######@ -H#####@+- -+H###@X
.,@##H; +XM##M/, =%@###@X;-
X%- :M##########$. .:%M###@%:
M##H, +H@@@$/-. ,;$M###@%, -
M####M=,,---,.-%%H####M$: ,+@##
@##################@/. :%H##@$-
M###############H, ;HM##M$=
#################. .=$M##M$=
################H..;XM##M$= .:+
M###################@%= =+@MH%
@#################M/. =+H#X%=
=+M###############M, ,/X#H+:,
.;XM###########H= ,/X#H+:;
.=+HM#######M+/+HM@+=.
,:/%XM####H/.
,.:=-.`;
//appa
//atom
//nuke
var options = [cake, heart, fire, tick, bang, mesa, cube];
let active = cake
function updateView() {
active = "<br>" + options[Math.floor((Math.random() * options.length))];
setTimeout(updateView, 5000);
}
onMount(() => updateView());
</script>
<svelte:head>
</svelte:head>
<body style="text-align: center">
<audio controls autoplay>
<source src="alive.ogg" type="audio/wav">
</audio>
<pre>{active}</pre>
<br>
This was a triumph!
I'm making a note here:
Huge success!
It's hard to overstate
my satisfaction.
Aperture Science:
We do what we must
because we can
For the good of all of us.
Except the ones who are dead.
But there's no sense crying
over every mistake.
You just keep on trying
'til you run out of cake.
And the science gets done.
And you make a neat gun
for the people who are
still alive.
I'm not even angry...
I'm being so sincere right now.
Even though you broke my heart,
and killed me.
And tore me to pieces.
And threw every piece into a fire.
As they burned it hurt because
I was so happy for you!
Now, these points of data
make a beautiful line.
And we're out of beta.
We're releasing on time!
So I'm GLaD I got burned!
Think of all the things we learned!
for the people who are
still alive.
Go ahead and leave me...
I think I'd prefer to stay inside...
Maybe you'll find someone else
to help you.
Maybe Black Mesa?
That was a joke. Ha Ha. Fat Chance!
Anyway this cake is great!
It's so delicious and moist!
Look at me: still talking
when there's science to do!
When I look out there,
it makes me glad I'm not you.
I've experiments to run.
There is research to be done.
On the people who are
still alive.
And believe me I am
still alive.
I'm doing science and I'm
still alive.
I feel fantastic and I'm
still alive.
While you're dying I'll be
still alive.
And when you're dead I will be
still alive
Still alive.
Still alive.
</body>
</html>

19
src/app.html Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#333333">
<meta name="description" content="Quartznet is a small team developing games, tools and more!">
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/global.css">
<link rel="manifest" href="manifest.json" crossorigin="use-credentials">
<link rel="icon" type="image/png" href="/img/favicon.ico">
%svelte.head%
</head>
<body>
<div id="svelte">%svelte.body%</div>
</body>
</html>

View File

@ -1,5 +0,0 @@
import * as sapper from '@sapper/app';
sapper.start({
target: document.querySelector('#sapper')
});

View File

@ -19,8 +19,6 @@
font-size: 3rem;
text-decoration: none;
}
</style>
<div class="overlay">

View File

@ -1,10 +0,0 @@
import App from './routes/index.svelte';
const app = new App({
target: document.body,
props: {
name: 'Quartznet'
}
});
export default app;

View File

@ -1,18 +0,0 @@
import sirv from 'sirv';
import polka from 'polka';
import compression from 'compression';
import * as sapper from '@sapper/server';
const {PORT, NODE_ENV} = process.env;
const dev = NODE_ENV === 'development';
polka() // You can also use Express
.use(
compression({threshold: 0}),
sirv('static', {dev}),
sapper.middleware()
)
.listen(PORT, err => {
if (err) console.log('error', err);
});
console.log('> DEV: ' + dev.toString())

View File

@ -1,82 +0,0 @@
import {timestamp, files, shell, routes} from '@sapper/service-worker';
const ASSETS = `cache${timestamp}`;
// `shell` is an array of all the files generated by the bundler,
// `files` is an array of everything in the `static` directory
const to_cache = shell.concat(files);
const cached = new Set(to_cache);
self.addEventListener('install', event => {
event.waitUntil(
caches
.open(ASSETS)
.then(cache => cache.addAll(to_cache))
.then(() => {
self.skipWaiting();
})
);
});
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(async keys => {
// delete old caches
for (const key of keys) {
if (key !== ASSETS) await caches.delete(key);
}
self.clients.claim();
})
);
});
self.addEventListener('fetch', event => {
if (event.request.method !== 'GET' || event.request.headers.has('range')) return;
const url = new URL(event.request.url);
// don't try to handle e.g. data: URIs
if (!url.protocol.startsWith('http')) return;
// ignore dev server requests
if (url.hostname === self.location.hostname && url.port !== self.location.port) return;
// always serve static files and bundler-generated assets from cache
if (url.host === self.location.host && cached.has(url.pathname)) {
event.respondWith(caches.match(event.request));
return;
}
// for pages, you might want to serve a shell `service-worker-index.html` file,
// which Sapper has generated for you. It's not right for every
// app, but if it's right for yours then uncomment this section
/*
if (url.origin === self.origin && routes.find(route => route.pattern.test(url.pathname))) {
event.respondWith(caches.match('/service-worker-index.html'));
return;
}
*/
if (event.request.cache === 'only-if-cached') return;
// for everything else, try the network first, falling back to
// cache if the user is offline. (If the pages never change, you
// might prefer a cache-first approach to a network-first one.)
event.respondWith(
caches
.open(`offline${timestamp}`)
.then(async cache => {
try {
const response = await fetch(event.request);
cache.put(event.request, response.clone());
return response;
} catch (err) {
const response = await cache.match(event.request);
if (response) return response;
throw err;
}
})
);
});

View File

@ -144,3 +144,9 @@ footer {
margin: 0 auto;
}
}
@media (max-width: 576px) {
footer {
flex-direction: column;
}
}

3
static/robots.txt Normal file
View File

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

15
svelte.config.js Normal file
View File

@ -0,0 +1,15 @@
import adapter from "@sveltejs/adapter-static";
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
// hydrate the <div id="svelte"> element in src/app.html
adapter: adapter({
pages: 'build',
// assets: 'static',
}),
target: '#svelte'
}
};
export default config;