Skip to content

Commit

Permalink
rfix
Browse files Browse the repository at this point in the history
  • Loading branch information
codediodeio committed Mar 3, 2024
1 parent 4191711 commit aa24f4f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions app/util/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ export class UniversalPlayer {
private async setupPlayer() {
if (this.type === 'youtube') {
const YouTubePlayer = (await import('youtube-player')).default;
const decoded = atob(this.video as string);
this.ytPlayer = YouTubePlayer(this.el);
this.ytPlayer.cueVideoById(this.video as string);
this.ytPlayer.cueVideoById(decoded);
} else {
const VimeoPlayer = (await import('@vimeo/player')).default;
this.vimeoPlayer = new VimeoPlayer(this.el, { id: this.video as number });
const decoded = parseInt(atob(this.video as string));
const buildId = parseInt(document.head.dataset.build);
this.vimeoPlayer = new VimeoPlayer(this.el, { id: decoded - buildId });
}

}

// Static constructor to await dynamic imports
Expand Down
9 changes: 6 additions & 3 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html class="dark">
<head>
<head data-build="{{ .Site.Data.svelte.token }}">
<meta charset="utf-8">
<title>{{ .Page.Title }}</title>
<link rel="shortcut icon" href="/img/favicon.png" type="image/x-icon">
Expand All @@ -25,10 +25,13 @@

</head>
<body>
{{ $vimeoEncode := cond (.Params.vimeo | not | not) (add (int .Params.vimeo) .Site.Data.svelte.token | base64Encode) "" }}
{{ $ytEncode := .Params.youtube | base64Encode }}

<global-data
permalink="{{ .Permalink }}"
vimeo="{{ .Params.vimeo }}"
youtube="{{ .Params.youtube }}"
vimeo="{{ $vimeoEncode }}"
youtube="{{ $ytEncode }}"
free="{{ .Params.free }}"
next="{{with .PrevInSection}}{{.Permalink}}{{end}}"
prev="{{with .NextInSection}}{{.Permalink}}{{end}}">
Expand Down
3 changes: 2 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ function syncToHugo() {
const assets = await readdir(svelteBuild);
const js = assets.filter(name => name.match(/(index.)(?!.*?esm)(?!.*?css).*\w+/))[0];
const css = assets.filter(name => name.includes('.css'))[0];
const token = Math.floor(Math.random() * 69420);
await Promise.all([
writeFile(`./data/svelte.json`, JSON.stringify({ js, css })),
writeFile(`./data/svelte.json`, JSON.stringify({ js, css, token })),
rm('./static/svelte/index.html')
]);
console.log(`wrote ${js} to hugo data`);
Expand Down

0 comments on commit aa24f4f

Please sign in to comment.