♻️ refactor: Move similar javascript inline code out of line

- Move variables oid, oid_likes out of line
- Move background-blur out of line
- Move fetch-repo code out of line
This commit is contained in:
Served Smart
2025-06-04 23:51:03 +02:00
parent 8387c6ea0a
commit 37ab1055e7
18 changed files with 100 additions and 155 deletions

View File

@@ -39,21 +39,9 @@
</div>
</div>
<script>
fetch({{ $gitlabURL }}, {
headers: new Headers({
'User-agent': 'Mozilla/4.0 Custom User Agent'
})
})
.then(response => response.json())
.then(data => {
document.getElementById('{{ $id }}-name_with_namespace').innerHTML = data.name_with_namespace;
document.getElementById('{{ $id }}-description').innerHTML = data.description;
document.getElementById('{{ $id }}-star_count').innerHTML = data.star_count;
document.getElementById('{{ $id }}-forks_count').innerHTML = data.forks_count;
})
.catch(error => console.error(error))
</script>
{{ $fetchRepo := resources.Get "js/fetch-repo.js" }}
{{ $fetchRepo = $fetchRepo | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }}
<script type="text/javascript" src="{{ $fetchRepo.RelPermalink }}" integrity="{{ $fetchRepo.Data.Integrity }}" data-url="{{ $gitlabURL }}" data-id="{{ $id }}"></script>
</a>
</div>
{{- end -}}