chore: refactor image setup
This commit is contained in:
parent
f5b480e195
commit
82a8a1f15a
20 changed files with 121 additions and 52 deletions
|
@ -169,7 +169,7 @@ The templating for my site is all written in [liquid.js](https://liquidjs.com) a
|
|||
</div>
|
||||
{%- capture artistImg %}{{ artist.name | artist }}{% endcapture -%}
|
||||
{%- capture artistName %}{{ artist.name | escape }}{% endcapture -%}
|
||||
{% image artistImg, artistName, 'rounded-lg', '225px', 'eager' %}
|
||||
{% image artistImg, artistName, 'rounded-lg' %}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
@ -192,7 +192,7 @@ The templating for my site is all written in [liquid.js](https://liquidjs.com) a
|
|||
</div>
|
||||
</div>
|
||||
{%- capture albumName %}{{ album.name | escape }}{% endcapture -%}
|
||||
{% image album.art, albumName, 'rounded-lg', '225px' %}
|
||||
{% image album.art, albumName, 'rounded-lg' %}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
@ -204,7 +204,7 @@ The templating for my site is all written in [liquid.js](https://liquidjs.com) a
|
|||
|
||||
We have an object containing arrays of objects — we iterate through each object for the appropriate section (tracks aren't displayed at the moment) and build the resulting display[^3]. This isn't perfect by any means, but, it does provide a nice little visualization of what I'm listening to and `240` tracks feels adequate as a rolling window into that activity.
|
||||
|
||||
{% image 'https://cdn.coryd.dev/blog/albums-artists.jpg', 'Albums and artists', 'w-full', '1200px' %}
|
||||
{% image 'https://cdn.coryd.dev/blog/albums-artists.jpg', 'Albums and artists', 'border border-purple-600 dark:border-purple-400 rounded-lg overflow-hidden [&>*]:w-full' %}
|
||||
|
||||
[^1]: There are some good options to do this, but there aren't a _ton_ and the age of some of the apps is concerning. [Marvis](https://appaddy.wixsite.com/marvis) is far and away your best choice here.
|
||||
[^2]: Making sure that you update the values you obtained, including the path to your downloaded `.p8` file.
|
||||
|
|
|
@ -7,6 +7,7 @@ tags:
|
|||
- development
|
||||
- JavaScript
|
||||
---
|
||||
|
||||
My now page consists of a number of similar sections — some bespoke text, a number of media grids and lists. The text is repeated once, the lists are easily templated out in [Liquid.js](https://liquidjs.com/) and the media grids are all quite similar. Given the prominence of the media grids on the page and the number of them I decided to consolidate them into a single template while also normalizing the data passed into them as best I could.<!-- excerpt -->
|
||||
|
||||
If you want to skip all the reading, the diff for this [is here](https://github.com/cdransf/coryd.dev/commit/6dda493d7b6c0435bac8ee2a55179e9e1afb7acd). There were a few steps to take to get this done. First I went ahead and took an existing media template and went to work reconciling the slight differences between the artist, album, book, tv and movie displays as follows:
|
||||
|
@ -37,7 +38,7 @@ If you want to skip all the reading, the diff for this [is here](https://github.
|
|||
{% endif %}
|
||||
</div>
|
||||
{%- capture size %}{% if shape == 'square' %}225px{% else %}180px{% endif %}{% endcapture -%}
|
||||
{% image item.image, alt, 'rounded-lg w-full h-full', size, loading %}
|
||||
{% image item.image, alt, 'rounded-lg w-full h-full' %}
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
|
|
@ -10,7 +10,7 @@ I've been using Fastmail for years now and have explored a number of different a
|
|||
|
||||
For now, I've approached filtering my mail by applying regular expressions to reasonably broad categories of incoming mail[^2]. My thinking with this approach is that will scale better over the long term by applying heuristics to common phrases and patterns in incoming mail without the need to apply rules to senders on a per address or domain basis.
|
||||
|
||||
{% image 'https://cdn.coryd.dev/blog/fastmail-workflow.jpg', 'A diagram of my Fastmail workflow', 'w-full', '1200px', 'eager' %}
|
||||
{% image 'https://cdn.coryd.dev/blog/fastmail-workflow.jpg', 'A diagram of my Fastmail workflow', 'border border-purple-600 dark:border-purple-400 rounded-lg overflow-hidden [&>*]:w-full' %}
|
||||
|
||||
## Alias-specific rules
|
||||
|
||||
|
|
|
@ -65,6 +65,6 @@ Rendering the output is as simple as:
|
|||
|
||||
{% endraw %}
|
||||
Leaving us with:
|
||||
{% image 'https://cdn.coryd.dev/blog/album-releases.jpg', 'Albums I\'m looking forward to', 'w-full', '1200px' %}
|
||||
{% image 'https://cdn.coryd.dev/blog/album-releases.jpg', 'Albums I\'m looking forward to', 'border border-purple-600 dark:border-purple-400 rounded-lg overflow-hidden [&>*]:w-full' %}
|
||||
|
||||
[^1]: At this point, a dev playground.
|
||||
|
|
|
@ -13,7 +13,7 @@ I made a minor update to how I'm normalizing TV data for display on my now page.
|
|||
|
||||
By _minor_ I mean one of those things that may well break inexplicably depending on where the data lands. Instead of returning a normalized array based directly off the data returned by [Trakt](https://trakt.tv)'s API I'm instead collecting episodes in an array, checking as I iterate through the response to see if an episode of the same show exists and replacing that object with a mutated object designed to display the range of episodes watched for the show.
|
||||
|
||||
{% image 'https://cdn.coryd.dev/blog/grouped-tv.jpg', 'Grouped TV episodes', 'w-full', '1200px' %}
|
||||
{% image 'https://cdn.coryd.dev/blog/grouped-tv.jpg', 'Grouped TV episodes', 'border border-purple-600 dark:border-purple-400 rounded-lg overflow-hidden [&>*]:w-full' %}
|
||||
|
||||
{% raw %}
|
||||
|
||||
|
|
|
@ -168,6 +168,6 @@ Finally, if the page this all lives on is loaded by a client without JavaScript
|
|||
|
||||
All of this, yields the single line at the bottom of this image — updated on each visit.
|
||||
|
||||
{% image 'https://cdn.coryd.dev/blog/now-playing.jpg', 'Now playing', 'w-full', '1200px' %}
|
||||
{% image 'https://cdn.coryd.dev/blog/now-playing.jpg', 'Now playing', 'border border-purple-600 dark:border-purple-400 rounded-lg overflow-hidden [&>*]:w-full' %}
|
||||
|
||||
[^1]: Plus explicit conditions matching David Bowie and Minor Threat.
|
||||
|
|
|
@ -132,7 +132,7 @@ This is most impactful on [my now page](https://coryd.dev/now) which is populate
|
|||
{% raw %}
|
||||
|
||||
```liquid
|
||||
{% image artistImg, artistName, 'rounded-lg', '225px', 'eager' %}
|
||||
{% image artistImg, artistName, 'rounded-lg' %}
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
@ -140,6 +140,6 @@ For this page in particular, the images that are rendered above the fold are set
|
|||
|
||||
All of these boilerplate steps leave us with a quick to load, accessible and resilient site:
|
||||
|
||||
{% image 'https://cdn.coryd.dev/blog/page-speed.jpg', 'Pagespeed scores for coryd.dev/now', 'w-full', '1200px' %}
|
||||
{% image 'https://cdn.coryd.dev/blog/page-speed.jpg', 'Pagespeed scores for coryd.dev/now', 'border border-purple-600 dark:border-purple-400 rounded-lg overflow-hidden [&>*]:w-full' %}
|
||||
|
||||
[^1]: It's easy, flexible and helps mitigate my lack of an eye for design by providing safe baselines.
|
||||
|
|
|
@ -133,7 +133,7 @@ _Cool_[^4]. GitHub triggers a rebuild of the site every hour, Netlify builds it,
|
|||
|
||||
There are some significant issues with this approach: it doesn't capture listens to an album in a loop (like me playing the new Outer Heaven record today — hails 🤘). It can get wonky when my diff function hits a track order that elicits a false positive return value.
|
||||
|
||||
{% image 'https://cdn.coryd.dev/blog/charlie.jpg', 'Charlie Day standing in front of "charts"', 'w-full', '1200px' %}
|
||||
{% image 'https://cdn.coryd.dev/blog/charlie.jpg', 'Charlie Day standing in front of charts', 'border border-purple-600 dark:border-purple-400 rounded-lg overflow-hidden [&>*]:w-full' %}
|
||||
|
||||
"But Cory there's last.fm." I hear this, I love last.fm, but I've got concerns about its age, ownership and maintenance. I don't want to be on the wrong end of a scream test when the wrong (right?) server rack gets decommissioned.
|
||||
|
||||
|
|
Reference in a new issue