diff --git a/config/filters/excerpt.js b/config/filters/excerpt.js index 86ddac4..32a67b0 100644 --- a/config/filters/excerpt.js +++ b/config/filters/excerpt.js @@ -1,5 +1,7 @@ const createExcerpt = (post, limit ) => { - const withoutTags = post.content.replace(/(<([^>]+)>)/gi, ""); + const withoutTags = post.content.replace(/(<([^>]+)>)/gi, "") + .replace(/[^\x20-\x7E]/gmi, " ") + .replace(/\s+/g, " ").trim(); if (withoutTags.length > limit) { return withoutTags.slice(0, limit) + " […]"; diff --git a/src/blog/posts/2024/3/using-git-actions-for-triggering-echo.md b/src/blog/posts/2024/3/using-git-actions-for-triggering-echo.md index 2a2868b..41183b4 100644 --- a/src/blog/posts/2024/3/using-git-actions-for-triggering-echo.md +++ b/src/blog/posts/2024/3/using-git-actions-for-triggering-echo.md @@ -4,6 +4,7 @@ date: 2024-03-08T11:12:00Z tags: - eleventy - tech +excerpt: "I decided to start using Robb Knight's Echo tool to syndicate my blog posts to Mastodon, and trigger Webmentions." --- I decided to start using [Robb Knight's Echo tool](https://echo.rknight.me), to syndicate my blog posts to Mastodon, and trigger Webmentions. I'm not going to go through the configuration of Echo here, the [project README](https://github.com/rknightuk/echo) has some good instructions for setting it up. diff --git a/src/blog/posts/2024/4/css-naked-day.md b/src/blog/posts/2024/4/css-naked-day.md index 542bdd3..b56d96b 100644 --- a/src/blog/posts/2024/4/css-naked-day.md +++ b/src/blog/posts/2024/4/css-naked-day.md @@ -4,6 +4,7 @@ description: My blog is going naked for CSS naked day tags: - css date: 2024-04-09T07:11:20.550Z +excerpt: "It's CSS Naked Day, so to celebrate I've stripped all of the CSS from my blog." --- It's [CSS Naked Day](https://css-naked-day.github.io/)[^1], so to celebrate I've stripped all of the CSS from my blog. diff --git a/src/blog/posts/2024/5/learning-go-day-1.md b/src/blog/posts/2024/5/learning-go-day-1.md index 47e4647..4aaf414 100644 --- a/src/blog/posts/2024/5/learning-go-day-1.md +++ b/src/blog/posts/2024/5/learning-go-day-1.md @@ -1,11 +1,11 @@ --- title: "Learning Go: Day One" -date: 2024-05-01T09:00:00.0Z +date: 2024-05-01T08:00:00.0Z tags: - tech - learning - go - - weblogpomo + - WeblogPoMo excerpt: "I've wanted to try learning Go for a while now, but have never got round to it. So I'm going to (attempt) to learn a little bit about it each day, and blog about it, with a view to building something with it by the end of the month." --- @@ -125,7 +125,7 @@ func multiply(a, b int) int { func main() { fmt.Println(sayHello()) var num int = multiply(2, 5) - fmt.Println(fmt.Sprintf("2 * 5 = %d", num)) + fmt.Printf("2 * 5 = %d\n", num) } ``` @@ -135,7 +135,7 @@ func main() { func main() { fmt.Println(sayHello()) num := multiply(2, 5) - fmt.Println(fmt.Sprintf("2 * 5 = %d", num)) + fmt.Printf("2 * 5 = %d\n", num) } ``` diff --git a/src/blog/posts/2024/5/learning-go-day-2.md b/src/blog/posts/2024/5/learning-go-day-2.md new file mode 100644 index 0000000..feec026 --- /dev/null +++ b/src/blog/posts/2024/5/learning-go-day-2.md @@ -0,0 +1,34 @@ +--- +title: ""Learning Go: Day Two" +date: 2024-05-02T08:00:00.0Z +tags: + - tech + - learning + - go + - WeblogPoMo +excerpt: "In part two, I take a look at how to organise code into packages" +--- + +Welcome to Part Two of my series on Learning Go for WeblogPoMo. In this part, I'm going to look at how to organise my code into separate packages, so that I don't have to store everything in once single file. + +## Creating a package + +This was fairly straightforward. Packages are noted by the `package ` directive at the start of the file. You can even see that in `main.go`, which has `package.main` at the start. So, to create a package I added a directory for it (I'm calling it `maths`[^1]), and then added a `maths.go` file to it. For now, I'll just move the `multiply` function to it: + +```go +package maths + +func multiply(a, b int) int { + return a * b +} +``` + +Fairly straightforward, right? + +## Importing and running the code + +## Wait, what? + +## The vendor directory + +[^1]: Yes, maths, not math \ No newline at end of file diff --git a/src/feeds/json.njk b/src/feeds/json.njk index 76c76d8..cff2498 100644 --- a/src/feeds/json.njk +++ b/src/feeds/json.njk @@ -26,7 +26,9 @@ "url": "{{ absolutePostUrl }}", "title": "{{ post.data.title }}", "content_html": {% if post.templateContent %}{{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) | dump | safe }}{% else %}""{% endif %}, - "date_published": "{{ post.date | dateToRfc3339 }}" + "date_published": "{{ post.date | dateToRfc3339 }}", + "tags": {{ post.data.tags | except("posts") | json | safe }}, + "summary": "{{ post | excerpt }}" } {% if not loop.last %},{% endif %} {%- endfor %} diff --git a/src/feeds/tags/json.njk b/src/feeds/tags/json.njk index c43a667..b29238c 100644 --- a/src/feeds/tags/json.njk +++ b/src/feeds/tags/json.njk @@ -28,7 +28,9 @@ eleventyImport: "url": "{{ absolutePostUrl }}", "title": "{{ post.data.title }}", "content_html": {% if post.templateContent %}{{ post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) | dump | safe }}{% else %}""{% endif %}, - "date_published": "{{ post.date | dateToRfc3339 }}" + "date_published": "{{ post.date | dateToRfc3339 }}", + "tags": {{ post.data.tags | except("posts") | json | safe }}, + "summary": "{{ post | excerpt }}" } {% if not loop.last %},{% endif %} {%- endfor %}