diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/blog/2022-12-30-blog-ready/blog-ready.md | 52 | ||||
| -rw-r--r-- | src/blog/2022-12-30-blog-ready/pc-planner.jpg | bin | 0 -> 6497789 bytes | |||
| -rw-r--r-- | src/blog/blog.md | 1 | ||||
| -rw-r--r-- | src/blog/feed.xml | 7 |
4 files changed, 60 insertions, 0 deletions
diff --git a/src/blog/2022-12-30-blog-ready/blog-ready.md b/src/blog/2022-12-30-blog-ready/blog-ready.md new file mode 100644 index 0000000..144e5e2 --- /dev/null +++ b/src/blog/2022-12-30-blog-ready/blog-ready.md | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | # Getting my blog ready for 2023 | ||
| 2 | |||
| 3 | My first year of blogging is about to end, and I am happy with what | ||
| 4 | I wrote. I wanted to write at least one post every month, and I did. I | ||
| 5 | intend to keep this pace next year, but I want to make this easier by | ||
| 6 | writing shorter posts from time to time. This is not a trivial task: | ||
| 7 | I found out that writing good *short* content is harder than writing | ||
| 8 | good *long* content! | ||
| 9 | |||
| 10 | But if I keep writing, [my blogs's index page](../) is going to become | ||
| 11 | messy at some point! It would be nice to divide these posts by year... | ||
| 12 | |||
| 13 | ## Adding year sections to my blog index | ||
| 14 | |||
| 15 | Very easy: in my | ||
| 16 | [build.sh](https://git.tronto.net/sebastiano.tronto.net/file/build.sh.html) | ||
| 17 | script that I run to | ||
| 18 | [build my website](../2022-08-14-website), there is a | ||
| 19 | [`makeblog()`](https://git.tronto.net/sebastiano.tronto.net/file/build.sh.html#l52) | ||
| 20 | function that takes care of building the index page and RSS feed for my blog. | ||
| 21 | |||
| 22 | It is enough to add the following lines inside its main loop: | ||
| 23 | |||
| 24 | ``` | ||
| 25 | thisyear=$(echo $d | sed 's/-.*//') | ||
| 26 | if [ "$thisyear" != "$lastyear" ]; then | ||
| 27 | printf "\n## $thisyear\n\n" >> $bf | ||
| 28 | lastyear=$thisyear | ||
| 29 | fi | ||
| 30 | ``` | ||
| 31 | |||
| 32 | And that's it! These few lines introduce two new variables, `thisyear` | ||
| 33 | and `lastyear`, that keep track of the years of the last and next blog | ||
| 34 | post that the loop is scanning. If there was a year change, a new line | ||
| 35 | with the current year is added, and the `lastyear` variable is updated. | ||
| 36 | The first line refers to a variable `d` that holds the date of the | ||
| 37 | current post in `yyyy-mm-dd` format. | ||
| 38 | |||
| 39 | A last note on the variables: if you are familiar with other programming | ||
| 40 | languages, you might wonder where the variable `lastyear` is initialized. | ||
| 41 | After all, I am using it in the `if` statement's condition, so it must | ||
| 42 | be initialized outside of its body, right? | ||
| 43 | |||
| 44 | Actually, no. The shell's variable scoping does not work like in C or | ||
| 45 | similar languages, and a variable initialized inside a block is also | ||
| 46 | visibile outside of it. Moreover, un-initialized variables evaluate to | ||
| 47 | the empty string, so the first time the condition is checked it correctly | ||
| 48 | determines that the current year is different from the last. | ||
| 49 | |||
| 50 | This was my last UNIX shell tip for this year. Stay tuned for more! | ||
| 51 | |||
| 52 |  | ||
diff --git a/src/blog/2022-12-30-blog-ready/pc-planner.jpg b/src/blog/2022-12-30-blog-ready/pc-planner.jpg new file mode 100644 index 0000000..8fb52e5 --- /dev/null +++ b/src/blog/2022-12-30-blog-ready/pc-planner.jpg | |||
| Binary files differ | |||
diff --git a/src/blog/blog.md b/src/blog/blog.md index 7498534..eddcd85 100644 --- a/src/blog/blog.md +++ b/src/blog/blog.md | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | ## 2022 | 6 | ## 2022 |
| 7 | 7 | ||
| 8 | * 2022-12-30 [Getting my blog ready for 2023](2022-12-30-blog-ready) | ||
| 8 | * 2022-12-24 [The man page reading club: ed(1)](2022-12-24-ed) | 9 | * 2022-12-24 [The man page reading club: ed(1)](2022-12-24-ed) |
| 9 | * 2022-11-23 [Self-hosted git pages with stagit (featuring ed, the standard editor)](2022-11-23-git-host) | 10 | * 2022-11-23 [Self-hosted git pages with stagit (featuring ed, the standard editor)](2022-11-23-git-host) |
| 10 | * 2022-10-19 [Keeping my email sorted (the hard way)](2022-10-19-email-setup) | 11 | * 2022-10-19 [Keeping my email sorted (the hard way)](2022-10-19-email-setup) |
diff --git a/src/blog/feed.xml b/src/blog/feed.xml index e84456a..f7edc90 100644 --- a/src/blog/feed.xml +++ b/src/blog/feed.xml | |||
| @@ -9,6 +9,13 @@ Thoughts about software, computers and whatever I feel like sharing | |||
| 9 | </description> | 9 | </description> |
| 10 | 10 | ||
| 11 | <item> | 11 | <item> |
| 12 | <title>Getting my blog ready for 2023</title> | ||
| 13 | <link>https://sebastiano.tronto.net/blog/2022-12-30-blog-ready</link> | ||
| 14 | <description>Getting my blog ready for 2023</description> | ||
| 15 | <pubDate>2022-12-30</pubDate> | ||
| 16 | </item> | ||
| 17 | |||
| 18 | <item> | ||
| 12 | <title>The man page reading club: ed(1)</title> | 19 | <title>The man page reading club: ed(1)</title> |
| 13 | <link>https://sebastiano.tronto.net/blog/2022-12-24-ed</link> | 20 | <link>https://sebastiano.tronto.net/blog/2022-12-24-ed</link> |
| 14 | <description>The man page reading club: ed(1)</description> | 21 | <description>The man page reading club: ed(1)</description> |
