diff --git a/assets/js/js-yaml.js b/assets/js/js-yaml.js
new file mode 100644
index 0000000..4690a6c
--- /dev/null
+++ b/assets/js/js-yaml.js
@@ -0,0 +1 @@
+export { dump, load } from 'js-yaml';
diff --git a/assets/js/octokit.js b/assets/js/octokit.js
new file mode 100644
index 0000000..e3d97f2
--- /dev/null
+++ b/assets/js/octokit.js
@@ -0,0 +1,4 @@
+import { Octokit as RealOctokit } from '@octokit/rest';
+import { throttling } from '@octokit/plugin-throttling';
+
+export const Octokit = RealOctokit.plugin(throttling);
diff --git a/content/convert-settings/convert.js b/content/convert-settings/convert.js
index ce56cf1..0ae5bb3 100644
--- a/content/convert-settings/convert.js
+++ b/content/convert-settings/convert.js
@@ -1,5 +1,5 @@
'use strict';
-import { load } from 'js-yaml';
+import { load } from '/js/js-yaml.js';
import TOML from '@ltd/j-toml';
function upgradeOldYaml(yaml) {
diff --git a/content/credits/credits.js b/content/credits/credits.js
index dbbc7a9..f3764e1 100644
--- a/content/credits/credits.js
+++ b/content/credits/credits.js
@@ -1,6 +1,4 @@
-'use strict';
-import { Octokit } from '@octokit/rest';
-import { throttling } from '@octokit/plugin-throttling';
+import { Octokit } from '/js/octokit.js';
// Commit 37e464f6001d440ae532516f40fe19162537475a and earlier are common
// between the loot and libloot repositories, so are double-counted by GitHub.
@@ -243,9 +241,7 @@ function fixStats(contributorsStats) {
}
async function getContributors() {
- const ThrottledOctokit = Octokit.plugin(throttling);
-
- const octokit = new ThrottledOctokit({
+ const octokit = new Octokit({
throttle: {
onAbuseLimit: () => true,
onRateLimit: () => true
diff --git a/content/search/search.js b/content/search/search.js
index 8fa0aeb..1ec9ca4 100644
--- a/content/search/search.js
+++ b/content/search/search.js
@@ -1,7 +1,5 @@
-'use strict';
-import { Octokit } from '@octokit/rest';
-import { throttling } from '@octokit/plugin-throttling';
-import { dump, load } from 'js-yaml';
+import { Octokit } from '/js/octokit.js';
+import { dump, load } from '/js/js-yaml.js';
// Globals
///////////////////
@@ -80,9 +78,7 @@ function onSearchInit(evt) {
console.log("Loading masterlist...");
progress.classList.remove('hidden');
- const ThrottledOctokit = Octokit.plugin(throttling);
-
- const octokit = new ThrottledOctokit({
+ const octokit = new Octokit({
throttle: {
onAbuseLimit: () => true,
onRateLimit: () => true
diff --git a/layouts/baseof.html b/layouts/baseof.html
index 4d3670b..ae2f81c 100644
--- a/layouts/baseof.html
+++ b/layouts/baseof.html
@@ -32,15 +32,22 @@
+{{ $externals := slice "/js/js-yaml.js" "/js/octokit.js" }}
+{{
+ $jsBuildOpts := dict
+ "format" "esm"
+ "minify" (not hugo.IsDevelopment)
+ "sourceMap" (cond hugo.IsDevelopment "external" "")
+ "target" "es2023"
+ "externals" $externals
+}}
+
+{{ (resources.Get "js/octokit.js" | js.Build $jsBuildOpts).Publish }}
+{{ (resources.Get "js/js-yaml.js" | js.Build $jsBuildOpts).Publish }}
+
{{ range .Resources.ByType "text" }}
{{ if eq .MediaType.Type "text/javascript" }}
- {{ $opts := dict
- "format" "esm"
- "minify" (not hugo.IsDevelopment)
- "sourceMap" (cond hugo.IsDevelopment "external" "")
- "target" "es2023"
- }}
- {{ $scriptSrc := . | js.Build $opts }}
+ {{ $scriptSrc := . | js.Build $jsBuildOpts }}
{{ end }}
{{ end }}