Only preload svg shapes on homepage

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-10-11 17:49:13 +02:00
parent 528744d765
commit 74581912f3
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
2 changed files with 10 additions and 3 deletions

View File

@ -7,9 +7,11 @@
<link rel="apple-touch-icon" href="/img/icons/apple-touch-icon-152x152.png" sizes="152x152" /> <link rel="apple-touch-icon" href="/img/icons/apple-touch-icon-152x152.png" sizes="152x152" />
<link rel="mask-icon" href="/img/icons/safari-pinned-tab.svg" color={theme_color()} /> <link rel="mask-icon" href="/img/icons/safari-pinned-tab.svg" color={theme_color()} />
<meta name="theme-color" content={theme_color()} /> <meta name="theme-color" content={theme_color()} />
<link rel="preload" href="/img/shape-1.svg" as="image" /> <%= if is_root(assigns) do %>
<link rel="preload" href="/img/shape-2.svg" as="image" /> <link rel="preload" href="/img/shape-1.svg" as="image" />
<link rel="preload" href="/img/shape-3.svg" as="image" /> <link rel="preload" href="/img/shape-2.svg" as="image" />
<link rel="preload" href="/img/shape-3.svg" as="image" />
<% end %>
<%= tags(assigns) || assigns.tags %> <%= tags(assigns) || assigns.tags %>
<%= Vite.inlined_phx_manifest() %> <%= Vite.inlined_phx_manifest() %>
<%= Vite.vite_client() %> <%= Vite.vite_client() %>

View File

@ -86,4 +86,9 @@ defmodule Mobilizon.Web.PageView do
def language_direction(assigns) do def language_direction(assigns) do
assigns |> Map.get(:locale, "en") |> get_language_direction() assigns |> Map.get(:locale, "en") |> get_language_direction()
end end
@spec is_root(map()) :: boolean()
def is_root(assigns) do
assigns |> Map.get(:conn, %{request_path: "/"}) |> Map.get(:request_path, "/") == "/"
end
end end