1
0
mirror of https://github.com/Damillora/Yuika synced 2024-11-14 22:07:32 +00:00
Yuika/partials/post-background.hbs

34 lines
1.1 KiB
Handlebars
Raw Normal View History

2019-11-08 20:59:26 +00:00
{{!--
Wow what the hell is going on in here even?
Ok so, several templates use this big header with a giant BG image. Nice idea, but big images
have a heavy impact on performance, so it's a good idea to make them responsive. Because we
can only get the image dynamically using Handlebars, and we can only set the image to properly
be a background image using CSS, we end up with a handful of inline styles.
If the template in question has a background image, then we render responsive image styles
for it, and apply those styles to the <header> tag. Else, we just output a <header> tag
with a `no-image` class so we can style it accordingly.
--}}
{{#if feature_image}}
<style type="text/css">
.responsive-{{slug}}-img {
2019-11-09 10:07:23 +00:00
background-image: url({{img_url feature_image size='m'}});
2019-11-08 20:59:26 +00:00
}
2019-11-09 10:07:23 +00:00
@media(max-width: 767px) {
2019-11-08 20:59:26 +00:00
.responsive-{{slug}}-img {
background-image: url({{img_url feature_image size='m'}});
}
}
</style>
2019-11-09 21:10:51 +00:00
<div class="h-64 responsive-{{slug}}-img bg-cover bg-center">
2019-11-08 20:59:26 +00:00
{{else}}
2019-11-09 21:10:51 +00:00
<div class="h-64 bg-gray-500">
2019-11-08 20:59:26 +00:00
{{/if}}