mirror of
https://github.com/mat-1/matdoesdev.git
synced 2025-08-02 06:36:04 +00:00
now sponsored by Stake
This commit is contained in:
parent
d96c8a6176
commit
20d0bd707d
3 changed files with 45 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy';
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import '../../app.css'
|
||||
import { fly } from 'svelte/transition'
|
||||
|
@ -7,15 +7,15 @@
|
|||
import { browser } from '$app/environment'
|
||||
import { writable } from 'svelte/store'
|
||||
import { onMount } from 'svelte'
|
||||
|
||||
|
||||
interface Props {
|
||||
data: LayoutData;
|
||||
data: LayoutData
|
||||
// + 1 because i live in the future
|
||||
copyrightYear?: any;
|
||||
children?: import('svelte').Snippet;
|
||||
copyrightYear?: any
|
||||
children?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let { data, copyrightYear = $bindable(new Date().getFullYear() + 1), children }: Props = $props();
|
||||
let { data, copyrightYear = $bindable(new Date().getFullYear() + 1), children }: Props = $props()
|
||||
|
||||
function clickCopyrightYear() {
|
||||
copyrightYear += 1
|
||||
|
@ -30,6 +30,22 @@
|
|||
|
||||
let stopGravity: (() => void) | null = null
|
||||
|
||||
// stake-ad.png easter egg
|
||||
let showStakeAd = false
|
||||
if (browser) {
|
||||
showStakeAd = getShowStakeAdFromUrl()
|
||||
if (showStakeAd) {
|
||||
;(async () => {
|
||||
const stakeAd = await import('./stake-ad')
|
||||
stakeAd.load()
|
||||
})()
|
||||
}
|
||||
}
|
||||
|
||||
function getShowStakeAdFromUrl() {
|
||||
return new URLSearchParams(location.search).has('stake')
|
||||
}
|
||||
|
||||
async function onPathChange() {
|
||||
// if we switched paths more than 10 times in the past 10 seconds, import $lib/gravity.js
|
||||
pathChangeTimestamps.push(Date.now())
|
||||
|
@ -51,6 +67,12 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add ?stake if necessary
|
||||
if (showStakeAd && !getShowStakeAdFromUrl()) {
|
||||
// this partially breaks back/forward navigation :(
|
||||
history.replaceState(null, '', '?stake')
|
||||
}
|
||||
}
|
||||
|
||||
const pageRendered = writable(false)
|
||||
|
@ -93,7 +115,7 @@
|
|||
$pageRendered = true
|
||||
})
|
||||
}
|
||||
run(() => {
|
||||
$effect(() => {
|
||||
if (browser) {
|
||||
if (previousPathname !== currentPathName) previousPathname = currentPathName
|
||||
currentPathName = data.pathname
|
||||
|
@ -104,7 +126,7 @@
|
|||
else flyDirection = -1
|
||||
onPathChange()
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
{#key data.pathname}
|
||||
|
|
15
src/routes/(main)/stake-ad.ts
Normal file
15
src/routes/(main)/stake-ad.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
let loaded = false
|
||||
|
||||
export function load() {
|
||||
if (loaded) return
|
||||
loaded = true
|
||||
|
||||
// add an <img src="/stake-ad.png" style="position: fixed" /> to the page
|
||||
const img = document.createElement('img')
|
||||
img.src = '/stake-ad.png'
|
||||
img.style.position = 'fixed'
|
||||
img.style.bottom = '0'
|
||||
img.style.right = '0'
|
||||
img.style.zIndex = '9999'
|
||||
document.body.appendChild(img)
|
||||
}
|
BIN
static/stake-ad.png
Normal file
BIN
static/stake-ad.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
Loading…
Add table
Reference in a new issue