🔒 🔧 Fixes #142 Optimize CDN service code

This commit is contained in:
elkan1788
2024-07-20 21:36:08 +08:00
parent 4e05bfb399
commit c5c1f03557
9 changed files with 102 additions and 43 deletions

View File

@@ -38,7 +38,7 @@
</main>
<footer class="footer">
<div class="footer-inner">
{{ partialCached "footer.html" . }}
{{ partial "footer.html" . }}
</div>
</footer>

View File

@@ -8,7 +8,7 @@
{{ end }}
{{ $file := .res.file }}
{{ if ne .vendor "unpkg" }}
{{ if ne .router.type "nodejs" }}
{{ with .res.alias }}
{{ $npm = . }}
{{ end }}
@@ -16,6 +16,6 @@
{{ $fmt = "%s/%s/%s/%s" }}
{{ end }}
{{ $pluginRes := printf $fmt .router $npm .res.version $file }}
{{ $pluginRes := printf $fmt .router.url $npm .res.version $file }}
{{ return $pluginRes }}

View File

@@ -43,15 +43,19 @@
{{ if .enable }}
<div class="vendors-list">
{{ range .list }}
<a target="_blank" href="{{ .link }}" title="{{ .name }}">
{{ if .image }}
<img src="/imgs/img-lazy-loading.gif" data-src="{{ .image.url }}" alt="{{ .name }}" />
{{ else }}
{{ .name }}
{{ end }}
</a>
<a target="_blank" href="{{ .link }}" title="{{ .name }}">
{{ if .image }}
<img src="/imgs/img-lazy-loading.gif" data-src="{{ .image.url }}" alt="{{ .name }}" />
{{ else }}
{{ .name }}
{{ end }}
</a>
{{ end }}
<span>{{ .title }}</span>
{{ $cv := $.Scratch.Get "router" }}
<a target="_blank" href="{{ $cv.home }}" title="{{ $cv.name }}">
<img src="/imgs/img-lazy-loading.gif" data-src="{{ $cv.logo }}" alt="{{ $cv.name }}" />
</a>
<span>{{ .title }}</span>
</div>
{{ end }}
{{ end }}

View File

@@ -21,7 +21,13 @@
{{ $globalVars.Set "tagsCount" (len .Site.Taxonomies.tags) }}
{{ $vendor := .Site.Params.vendors.plugins }}
{{ $router := index .Site.Data.resources.vendors $vendor }}
{{ $router := dict }}
{{ range .Site.Data.resources.vendors }}
{{ if eq .name $vendor }}
{{ $router = . }}
{{ break }}
{{ end }}
{{ end }}
{{ $globalVars.Set "vendor" $vendor }}
{{ $globalVars.Set "router" $router }}

View File

@@ -3,8 +3,8 @@
{{ $vendor := .Site.Params.vendors.plugins }}
{{ $router := .Scratch.Get "router" }}
{{ range $jsRes }}
{{ $pluginJS := partial "_funs/get_res.html" (dict "res" . "vendor" $vendor "router" $router) }}
<script type="text/javascript" src="{{ $pluginJS }}" defer></script>
{{ $pluginJS := partial "_funs/get_res.html" (dict "res" . "vendor" $vendor "router" $router) }}
<script type="text/javascript" src="{{ $pluginJS }}" crossorigin="anonymous" defer></script>
{{ end }}
<script class="next-config" data-name="main" type="application/json">{{ .Scratch.Get "config" }}</script>