Skip to content

Commit 170f868

Browse files
adjusted the loading priority of images/fonts (#356)
* made sure that important logos are inlined * made sure that the loading priority better reflects our intentions * formatting fixes
1 parent 38de434 commit 170f868

File tree

8 files changed

+44
-34
lines changed

8 files changed

+44
-34
lines changed

content/_index.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: MapLibre
33
menu: footer
44
weight: -10
5+
description: The MapLibre Organization is an umbrella for open-source mapping libraries.
56
---
67

78
<div class="container">
@@ -11,12 +12,7 @@
1112
<div class="home-banner">
1213
<div class="row align-items-center" style="padding: 0px 10px;">
1314
<div>
14-
<object
15-
style="margin: 0 auto;"
16-
width="353"
17-
data="/img/maplibre-logo.svg"
18-
type="image/svg+xml"
19-
></object>
15+
{{< svg src="static/img/maplibre-logo.svg" width="353px" style="margin: 0 auto;" >}}
2016

2117
<p style="word-break:normal; margin-top:30px; max-width: 800px;">
2218
The MapLibre Organization is an umbrella for open-source mapping

layouts/author/footer.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
<div class="row py-3">
77
<div class="col-4">
88
<a href="/" aria-label="MapLibre">
9-
<object
10-
height="30"
11-
width="120"
12-
data="/img/maplibre-logo.svg"
13-
type="image/svg+xml"
14-
></object>
9+
{{ partial "svg.html" (dict "src" "static/img/maplibre-logo.svg" "height" "30px" "width" "120px") }}
10+
1511

1612
<!--
1713
<svg

layouts/partials/footer.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
<div class="row py-3">
77
<div class="col-4">
88
<a href="/" aria-label="MapLibre">
9-
<object
10-
height="30"
11-
width="120"
12-
data="/img/maplibre-logo.svg"
13-
type="image/svg+xml"
14-
></object>
9+
{{ partial "svg.html" (dict "src" "static/img/maplibre-logo.svg" "height" "30px" "width" "120px") }}
10+
1511

1612
<!--
1713
<svg

layouts/partials/head.html

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,30 @@
3434
<link rel="me" href="https://mastodon.social/@maplibre" />
3535

3636
{{ $options := (dict "includePaths" (slice "node_modules") "transpiler" "libsass") }}
37-
{{ $style := resources.Get "style.scss" | resources.ToCSS $options | resources.Minify |
38-
resources.Fingerprint
39-
}}
37+
{{ $style := resources.Get "style.scss" | resources.ToCSS $options | resources.Minify }}
4038
<link rel="stylesheet" href="{{ $style.RelPermalink }}" />
39+
<link
40+
rel="preload"
41+
href="/files/alata-latin-400-normal.woff2"
42+
as="font"
43+
type="font/woff2"
44+
crossorigin
45+
/>
4146

42-
{{ $style := readFile "node_modules/maplibre-gl/dist/maplibre-gl.css" | resources.FromString "mapbox-gl.css" |
43-
resources.Fingerprint
44-
}}
47+
{{ $style := readFile "node_modules/maplibre-gl/dist/maplibre-gl.css" | resources.FromString "maplibre-gl.css" }}
4548
<link rel="stylesheet" href="{{ $style.RelPermalink }}" />
49+
<link
50+
rel="preload"
51+
href="https://demotiles.maplibre.org/style.json"
52+
as="fetch"
53+
crossorigin
54+
/>
55+
<link
56+
rel="preload"
57+
href="https://demotiles.maplibre.org/tiles/tiles.json"
58+
as="fetch"
59+
crossorigin
60+
/>
4661

4762
{{ $opts := dict "targetPath" "main.js" }}
4863
{{ $built := resources.Get "main.js" | js.Build $opts | resources.Fingerprint }} <script type="text/javascript" src="{{ $built.RelPermalink }}"></script>

layouts/partials/nav.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77
>
88
<div class="container">
99
<a class="navbar-brand" href="/" aria-label="MapLibre">
10-
<object
11-
height="30"
12-
width="120"
13-
data="/img/maplibre-logo.svg"
14-
type="image/svg+xml"
15-
></object>
10+
{{ partial "svg.html" (dict "src" "static/img/maplibre-logo.svg" "height" "30px" "width" "120px") }}
1611
</a>
1712
<div class="d-flex">
1813
<button

layouts/partials/svg.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<span
2+
style="
3+
{{- with .width }}width:{{ . }};{{ end -}}
4+
{{- with .height }}height:{{ . }};{{ end -}}
5+
display: inline-block;"
6+
>
7+
{{ .src | readFile | safeHTML }}
8+
</span>

layouts/shortcodes/svg.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
{{ $svg := .Get 0 }}
2-
<span style="width: 20px; display: inline-block;">
3-
{{ $svg | readFile | safeHTML }}
1+
<span
2+
style="
3+
{{- with .Get "width" }}width:{{ . }};{{ end -}}
4+
{{- with .Get "height" }}height: {{ . }};{{ end -}}
5+
display: inline-block;"
6+
>
7+
{{ .Get "src" | readFile | safeHTML }}
48
</span>

static/img/maplibre-logo.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)