mirror of
https://github.com/loot/loot.github.io.git
synced 2026-07-27 14:13:30 -07:00
Share js-yaml and Octokit between page scripts
js-yaml could probably be shared without the intermediate module, but is handled the same way as Octokit for consistency.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export { dump, load } from 'js-yaml';
|
||||
@@ -0,0 +1,4 @@
|
||||
import { Octokit as RealOctokit } from '@octokit/rest';
|
||||
import { throttling } from '@octokit/plugin-throttling';
|
||||
|
||||
export const Octokit = RealOctokit.plugin(throttling);
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+14
-7
@@ -32,15 +32,22 @@
|
||||
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
|
||||
<link rel="stylesheet" href="{{ $cssOverrides.RelPermalink }}">
|
||||
|
||||
{{ $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 }}
|
||||
<script src="{{ $scriptSrc.RelPermalink }}" type="module"></script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
Reference in New Issue
Block a user