refactor(repo-card): use iife and async loading

This commit is contained in:
ZhenShuo Leo
2025-06-20 22:15:27 +08:00
parent 91fe08d205
commit d39a64afe1
6 changed files with 7 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
async function fetchRepo() {
(async () => {
const script = document.currentScript;
const repoURL = script?.getAttribute("data-repo-url");
const repoId = script?.getAttribute("data-repo-id");
@@ -54,6 +54,4 @@ async function fetchRepo() {
} catch (error) {
console.error(error);
}
}
fetchRepo();
})();

View File

@@ -52,6 +52,7 @@
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script
async
type="text/javascript"
src="{{ $fetchRepo.RelPermalink }}"
integrity="{{ $fetchRepo.Data.Integrity }}"

View File

@@ -52,6 +52,7 @@
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script
async
type="text/javascript"
src="{{ $fetchRepo.RelPermalink }}"
integrity="{{ $fetchRepo.Data.Integrity }}"

View File

@@ -52,6 +52,7 @@
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script
async
type="text/javascript"
src="{{ $fetchRepo.RelPermalink }}"
integrity="{{ $fetchRepo.Data.Integrity }}"

View File

@@ -68,6 +68,7 @@
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script
async
type="text/javascript"
src="{{ $fetchRepo.RelPermalink }}"
integrity="{{ $fetchRepo.Data.Integrity }}"

View File

@@ -41,6 +41,7 @@
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script
async
type="text/javascript"
src="{{ $fetchRepo.RelPermalink }}"
integrity="{{ $fetchRepo.Data.Integrity }}"