Add theme_asset filter

- Update themes to use theme_asset filter
This commit is contained in:
Daniel J. Summers 2022-05-31 08:00:32 -04:00
parent 5daf18e01d
commit 042e1fdec7
6 changed files with 23 additions and 16 deletions

View File

@ -150,6 +150,12 @@ type TagLinkFilter () =
|> function tagUrl -> WebLog.relativeUrl (webLog ctx) (Permalink $"tag/{tagUrl}/")
/// A filter to generate a link for theme asset (image, stylesheet, script, etc.)
type ThemeAssetFilter () =
static member ThemeAsset (ctx : Context, asset : string) =
$"/themes/{(webLog ctx).themePath}/{asset}"
/// Create links for a user to log on or off, and a dashboard link if they are logged off
type UserLinksTag () =
inherit Tag ()

View File

@ -211,7 +211,8 @@ let main args =
// Set up DotLiquid
[ typeof<AbsoluteLinkFilter>; typeof<CategoryLinkFilter>; typeof<EditPageLinkFilter>; typeof<EditPostLinkFilter>
typeof<NavLinkFilter>; typeof<RelativeLinkFilter>; typeof<TagLinkFilter>; typeof<ValueFilter>
typeof<NavLinkFilter>; typeof<RelativeLinkFilter>; typeof<TagLinkFilter>; typeof<ThemeAssetFilter>
typeof<ValueFilter>
]
|> List.iter Template.RegisterFilter

View File

@ -11,7 +11,7 @@
<header class="site-header">
<div class="header-logo">
<a href="{{ "" | relative_link }}">
<img src="/themes/{{ web_log.theme_path }}/bitbadger.png"
<img src="{{ "bitbadger.png" | theme_asset }}"
alt="A cartoon badger looking at a computer screen, with his paw on a mouse"
title="Bit Badger Solutions">
</a>
@ -20,10 +20,10 @@
<div class="header-spacer"> &nbsp; </div>
<div class="header-social">
<a href="https://twitter.com/Bit_Badger" title="Bit_Badger on Twitter" target="_blank">
<img src="/themes/{{ web_log.theme_path }}/twitter.png" alt="Twitter">
<img src="{{ "twitter.png" | theme_asset }}" alt="Twitter">
</a> &nbsp;
<a href="https://www.facebook.com/bitbadger.solutions" title="Bit Badger Solutions on Facebook" target="_blank">
<img src="/themes/{{ web_log.theme_path }}/facebook.png" alt="Facebook">
<img src="{{ "facebook.png" | theme_asset }}" alt="Facebook">
</a>
</div>
</header>

View File

@ -18,8 +18,8 @@
<div class="app-info">
<article class="content">
<aside>
<img src="/themes/{{ web_log.theme_path }}/screenshots/{{ page.permalink | split: "/" | last }}.png"
alt="Screen shot of {{ page.title | escape }}">
{%- capture screen_url %}screenshots/{{ page.permalink | split: "/" | last }}.png{% endcapture -%}
<img src="{{ screen_url | theme_asset }}" alt="Screen shot of {{ page.title | escape }}">
</aside>
{{ page.text }}
{%- assign curr_tech = page.metadata | where: "name", "tech" -%}

View File

@ -13,9 +13,9 @@
</title>
<link rel="preload" href="https://fonts.googleapis.com/css?family=Quicksand|Oswald" as="style">
<link rel="preload" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" as="style">
<link rel="preload" href="/themes/{{ web_log.theme_path }}/style.css" as="style">
<link rel="preload" href="{{ "style.css" | theme_asset }}" as="style">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<script src="/themes/{{ web_log.theme_path }}/djs.js"></script>
<script src="{{ "djs.js" | theme_asset }}"></script>
{% page_head -%}
</head>
<body>
@ -73,8 +73,8 @@
<div class="football-panel">
<span>
<a href="https://utsports.com" style="background:none;padding:0;" target="_blank" rel="noopener">
<img src="/themes/{{ web_log.theme_path }}/tennessee.png" alt="T" title="Tennessee Sports"
style="border:0;" width="75px">
<img src="{{ "tennessee.png" | theme_asset }}" alt="T" title="Tennessee Sports" style="border:0;"
width="75px">
</a>
</span>
<div>
@ -92,7 +92,7 @@
<div class="football-panel">
<span>
<a href="https://csurams.com" style="background:none;padding:0;" target="_blank" rel="noopener">
<img src="/themes/{{ web_log.theme_path }}/csurams.png" alt="CSU Rams Logo"
<img src="{{ "csurams.png" | theme_asset }}" alt="CSU Rams Logo"
title="Colorado State Sports" style="border:0;" height="75px" width="75px">
</a>
</span>

View File

@ -17,7 +17,7 @@
<header class="site-header">
<div class="header-logo">
<a href="{{ "" | relative_link }}">
<img src="/themes/tech-blog/img/bitbadger.png"
<img src="{{ "img/bitbadger.png" | theme_asset }}"
alt="A cartoon badger looking at a computer screen, with his paw on a mouse"
title="Bit Badger Solutions">
</a>
@ -26,13 +26,13 @@
<div class="header-spacer">&nbsp;</div>
<div class="header-social">
<a href="{{ "feed.xml" | relative_link }}" title="Subscribe to The Bit Badger Blog via RSS">
<img src="/themes/tech-blog/img/rss.png" alt="RSS">
<img src="{{ "img/rss.png" | theme_asset }}" alt="RSS">
</a> &nbsp; &nbsp;
<a href="https://twitter.com/Bit_Badger" title="Bit_Badger on Twitter">
<img src="/themes/tech-blog/img/twitter.png" alt="Twitter">
<img src="{{ "img/twitter.png" | theme_asset }}" alt="Twitter">
</a> &nbsp; &nbsp;
<a href="https://www.facebook.com/bitbadger.solutions" title="Bit Badger Solutions on Facebook">
<img src="/themes/tech-blog/img/facebook.png" alt="Facebook">
<img src="{{ "img/facebook.png" | theme_asset }}" alt="Facebook">
</a>
</div>
</header>