More work on getting blog looking good

This commit is contained in:
Lewis Dale 2023-02-14 17:00:01 +00:00
parent 81bc038016
commit d0a681c927
15 changed files with 214 additions and 19 deletions

View File

@ -12,6 +12,7 @@ const markdownitAbbr = require('markdown-it-abbr');
const markdownItEleventyImg = require('markdown-it-eleventy-img');
const icons = require('./icons.json');
const { slugifyString } = require('../utils');
const markdownLib = markdownIt({
html: true,
breaks: true,
@ -70,5 +71,6 @@ const markdownLib = markdownIt({
};
module.exports = function(eleventyConfig) {
eleventyConfig.addFilter('md', content => content ? markdownLib.render(content) : "");
eleventyConfig.setLibrary('md', markdownLib);
};

View File

@ -7,7 +7,7 @@
"serve": "run-p \"serve:*\"",
"serve:props": "node scripts/custom-props.js",
"serve:css": "postcss src/css/styles.css --base src --dir _site/assets -w",
"serve:eleventy": "eleventy --serve",
"serve:eleventy": "eleventy --serve --incremental",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",

View File

@ -1,6 +1,7 @@
{
"author": {
"name": "Lewis Dale"
"name": "Lewis Dale",
"avatar": "src/images/me.jpg"
},
"site": {
"name": "LewisDale.dev",

View File

@ -5,4 +5,8 @@ layout: base.njk
<article class="wrapper-lg stack-md">
<h1><a href="{{ post.url }}">{{ title }}</a></h1>
{{ content | safe }}
</article>
</article>
<author class="wrapper-lg">
{% image metadata.author.avatar, "My face", "box circle", "150px", [150] %}
</author>

View File

@ -3,21 +3,28 @@ title: Blog
layout: base.njk
pagination:
data: collections.posts
size: 10
size: 5
reverse: true
---
<main class="wrapper-lg stack-lg">
<h1>Blog posts</h1>
<h1>Blog posts</h1>
<ol class="stack-md">
{% for item in pagination.items %}
<li>
<h2><a href="{{ item.url }}">{{ item.data.title }}</a></h2>
<p>
{% set excerpt = item.page.excerpt %}
{% renderFile "./src/_includes/components/excerpt.md", item.page %}
</p>
</li>
{% endfor %}
</ol>
<ol class="stack-xl">
{% for item in pagination.items %}
<li class="stack-xs">
<h2><a href="{{ item.url }}">{{ item.data.title }}</a></h2>
<time class="block">{{ item.date | dateDisplay }}</time>
{{ item.page.excerpt | md | safe }}
<a href="{{ item.url }}" class="inline-block">Read more</a>
</li>
{% endfor %}
</ol>
<nav class="blog-nav row" data-spacing="between">
{% if pagination.href.next %}
<a href="{{ pagination.href.next }}">Older</a>
{% endif %}
{% if pagination.href.previous %}
<a href="{{ pagination.href.previous }}">Newer</a>
{% endif %}
</nav>
</main>

View File

@ -0,0 +1,61 @@
---
layout: post
title: Microblogging with Eleventy
date: 2022-12-30T21:24:54.088Z
tags:
- posts
- eleventy
---
Given the drive to move all of my content into one place and syndicate it to other networks, I decided that I'd also try out doing microblog-style posts with Eleventy. Before I could do that, I needed to add a CMS (there's no way I'm manually adding Markdown files everytime I want to post a status).
---
Once that was done, I added a new collection for Microblog posts, which are just text fields with a posting datetime - no title, or any of the other frontmatter data that I'd normally add to a full blog post.
I also modified Netlify CMS to enable a max length on textarea fields - Mastodon Toots are 500 characters, so that's where I drew the line.
Finally, I created a new [RSS feed](https://lewisdale.dev/micro/feed.xml) for my microblog posts - this will also be important later when I want to publish to other platforms.
## Syndicating
I've already added [Webmentions](https://indieweb.org/Webmention) to my website, which allow me to send and receive certain types of interactions from other websites. These map pretty nicely to certain social media interactions, like replies, reblogs, and likes.
To start with, I need to be able to send out Webmentions when they're included. To do this, I use [Webmention.io](https://webmention.io), which provides me a webhook I can call. Then, I use [IFTTT](https://ifttt.com) to trigger the webhook when it detects a new RSS feed item.
The final step is to use [Bridgy](https://brid.gy) to handle cross-posting. This is done by including the webmention syndication URL in the post body as an invisible anchor. For cross-posting to work, I need to markup my post using [Microformats](https://indieweb.org/microformats)
For blog posts, this means adding `h-entry` with `e-content` and `p-name` tags. Bridgy will detect these, determine that it's an article, and cross-post just the article title and a link.
```twig
<article class="h-entry">
<h1 class="p-name">{{ title }}</h1>
<div class="e-content">
{{ content | safe }}
</div>
<div class="syndication">
<a href="https://brid.gy/publish/mastodon"></a>
</div>
</article>
```
For microblog posts, this is slightly different. Bridgy assumes that a post is an article if it contains a `p-name` tag, so I omit that. In it's place I include the timestamp, which is slightly more important for these:
{% raw %}
```twig
<article class="h-entry">
<time class="dt-published">{{ date | microDate }}</time>
<div class="flow e-content">
{{ content | safe }}
</div>
<div class="syndication">
<a href="https://brid.gy/publish/mastodon"></a>
</div>
</article>
```
{% endraw %}
## Next steps
This works reasonably well - there's a fairly large delay between publishing on my site and syndicating across to different platforms. That's mostly because there are several different intermediaries that have to be triggered in turn (IFTTT -> Webhooks -> Webmention -> Brid.gy -> Mastodon). In fairly short order I'd like to replace at least some of this with my own code. I already use post-deploy Netlify functions to send ActivityPub messages, so I may as well use it for other syndication too.
I also want to improve some of the markup on my microblog posts, and add a proper feed to my home page. But that'll also come with a bit of a site redesign, because I'm getting bored of this one.

View File

@ -0,0 +1,32 @@
---
title: A new blog
description: I've just finished redesigning a new blog, after not having one for a long time
date: 2021-12-17
---
It's been a long time since I've had an actively-maintained personal website/blog, but I got a spurt of inspiration after seeing a few other recently-revamped blogs. What better way to celebrate the end of the year than with... a blog?
My intention is to try and write a post on here relatively frequently, but we'll see how that goes as I'm quite out of practice.
## Tech stack
I wanted this website to achieve three things: be of my own design, be easy to update, and be accessible. To that end, I chose a relatively simple tech stack:
- [Eleventy](https://11ty.dev)
- HTML
- CSS
And that's... just about it. Eleventy gives me more than enough functionality to write simple blog posts in Markdown, convert them to HTML, and display them on a page.
I did start out using [Tailwind](https://tailwindcss.com), but after a little while and seeing some of the recent discourse around it, I decided I wanted to write all the styles myself from scratch. It was pretty easy to remove Tailwind from the stack, as I hadn't done too much work on it to begin with. Plus, it meant that I could get rid of PostCSS, which was giving me a headache when trying to serve both PostCSS and Eleventy at the same time.
I deployed the site using [Netlify](https://netlify.app). It was my first time using it, and to be honest I'm pretty impressed by how quickly I was able to get things up and running. It took maybe 3 minutes from signing up to getting a version of the site deployed (pointing the domain took longer thanks to pesky DNS propagation times).
## Accessibility and Performance
I wanted some assurance that my website would be accessible, so I regularly tested my pages with [axe DevTools](https://www.deque.com/axe/devtools/) and Lighthouse in Chrome.
At the time of writing, there are no accessibility issues reported by Axe or Lighthouse, so that's a win!
If anybody reading this does in fact spot or experience an accessibility issue, [please send me a DM or tweet on Twitter](https://twitter.com/LewisDaleUK).

View File

@ -0,0 +1,48 @@
---
title: Solving 2048 Using A* Search
description: One of my recent project has been to attempt to solve the game 2048 using A* Search
date: 2014-05-23
tags:
- algorithms
- archive
---
One of my recent projects has been to attempt to solve the game 2048 using A* Search - it all started from a bet with my girlfriend about who could get the highest score, and I decided Id “cheat” and just get my computer to do it for me. It didnt work, she still managed to get to the 2048 tile first.
To start with, I wrote a command-line version of the 2048 game in Java - it was fairly simple, if a little unncessary, and worked well - I even had a little play of it before implementing the A* algorithm, and it was fairly fun to play. There were no real issues here, just a small amount of confusion about how to implement the “gravity” style of tile movement, but a little thought sorted that one out.
Then it came to actually writing the A* Search. I was lucky, in that I had a template from a previous University assignment to work from. All there really was to do was swap a few classes and methods, and change the heuristics.
## The Heuristic
The heuristic I am using at the minute is a less-than-optimal one, but it was the first one I tried. I was actually quite surprised at how effective it was.
```
(0 - sum of tiles) + solution depth
```
Like I say, this is not optimal, and certainly does not provide the highest-scoring solutions. But it does give fairly high scores, and certainly finds the 2048 tile - and even the 4096 tile.
Oher possible heuristics include:
* (0 - score) + solution depth
* Difference between largest tile and 2048 tile
* Mean value of tiles
There are a lot of options, and I have seen some impressive implementations. I look forward to improving this further.
## The Pseudocode
Heres a snippet of pseudocode for the A* algorithm:
```
While queue is not empty
if game is solved
print current state
end running
else
get next state from queue
add children of current state to queue
endwhile
```
## Screenshots

View File

@ -0,0 +1,15 @@
---
title: The web is exhausting
description: Some thoughts about using - and developing for - the web
date: 2022-08-31
tags:
- meta
---
I've been using the web in some form for over 20 years - granted, the early parts of that were heavily monitored because I was about 5 years old when we got dialup. But, a large part of my formative years were spent online, and it was such a different place compared to how it is today.
I remember spending hours on different websites, which were mostly forums dedicated to a single topic, speaking with a variety of people (although the same few names were usually present). The web felt _huge_ back then, a vast array of small communities. It feels like the total commercialisation of the web has taken that from us, though. I now visit maybe 3 websites regularly, and just endlessly, mindlessly doomscroll. I can honestly say that using the web these days is so much less exciting and fun compared to what it used to be.
It's not just become exhausting as a consumer, though. A lot of the modern tooling available to web developers is overwhelmingly complicated. This post came about because I considered building a small web app using WebGL and Javascript - I decided I wanted a bit of type safety, and to use one library, (Three.js). Then I looked at the number of steps required just to get Typescript working nicely with ThreeJS and gave up. It shouldn't be this hard to build web applications, I shouldn't have a development directory that regularly exceeds 1gb per project because there are thousands of dependencies.
It's not all doom and gloom, thankfully. There are tons of people making interesting, fun, and exciting content for the web. They're just harder to find these days. And there _are_ simple tools for building web applications (this blog is <a href="https://11ty.dev">built using one</a>), and I don't _need_ the libraries or Typescript to build apps, they're just nice to have.

View File

@ -0,0 +1,13 @@
---
title: Thinking about the web
description: Mulling over how best to use this website
date: 2022-12-28
tags:
- personal
---
I've been seeing some good posts recently, like these ones from [Andy Bell](https://andy-bell.co.uk/bring-back-blogging/), [Chris Coyier](https://chriscoyier.net/2022/12/26/bring-back-blogging/), and [Sophie Koonin](https://localghost.dev/blog/building-a-website-like-it-s-1999-in-2022/), about using a blog as a real "base" for your place on the web, and then following the [POSSE principle](https://indieweb.org/POSSE) for everywhere else.
I like that idea - this is the one part of the web I have the most control over. It's already partially-federated (with some improvements coming this way in the near future). I just need to set up some more syndication tools using IFTTT, and then I think I'll be good to go.
I'd like to add a second post format too, for shorter-form posts that I'd normally have written for Twitter - as well as making it a bit easier to publish content. But that means getting a CMS of some description, so might take me a little while.

View File

@ -4,3 +4,7 @@
gap: var(--vertical-spacing, 1rem);
flex-wrap: wrap;
}
.row[data-spacing="between"] {
justify-content: space-between;
}

View File

@ -0,0 +1,4 @@
.blog-nav {
border-top: 1px solid var(--color-neutral-200);
padding-top: var(--space-size-2xs);
}

View File

@ -28,4 +28,8 @@
font-style: italic;
font-weight: 300;
}
p {
max-width: 50ch;
}
}

View File

@ -19,7 +19,7 @@ h5 {
h1 {
font-size: var(--text-size-xl);
word-wrap: normal;
text-underline-offset: var(--space-size-2xs);
text-underline-offset: var(--space-size-3xs);
}
h2 {
@ -61,7 +61,7 @@ header {
p {
line-height: 1.6;
max-width: 50ch;
max-width: 60ch;
}
footer {

View File

@ -10,7 +10,7 @@ layout: base.njk
I'm a software engineer who loves building things for the web. I consider myself a generalist, but on a given day I'll probably be working with Typescript, HTML and CSS, and on occasion a touch of .NET. I work for <a href="https://triptease.com" target="_blank" rel="noreferrer">Triptease</a> as a Senior Software Engineer, and on the side I'm learning Rust by building a <a href="/blog/category/basic">Sinclair BASIC Interpreter</a>.
</p>
{% image "src/images/me.jpg", "My face", "box circle", "300px", [300] %}
{% image metadata.author.avatar, "My face", "box circle", "300px", [300] %}
<p>
When I'm not working I love cycling, reading fiction (mostly sci-fi and ghost stories), and spending time with my family & our border collie.