aboutsummaryrefslogtreecommitdiff
path: root/src/blog
diff options
context:
space:
mode:
Diffstat (limited to 'src/blog')
-rw-r--r--src/blog/2022-12-30-blog-ready/blog-ready.md52
-rw-r--r--src/blog/2022-12-30-blog-ready/pc-planner.jpgbin0 -> 6497789 bytes
-rw-r--r--src/blog/blog.md1
-rw-r--r--src/blog/feed.xml7
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
3My first year of blogging is about to end, and I am happy with what
4I wrote. I wanted to write at least one post every month, and I did. I
5intend to keep this pace next year, but I want to make this easier by
6writing shorter posts from time to time. This is not a trivial task:
7I found out that writing good *short* content is harder than writing
8good *long* content!
9
10But if I keep writing, [my blogs's index page](../) is going to become
11messy at some point! It would be nice to divide these posts by year...
12
13## Adding year sections to my blog index
14
15Very easy: in my
16[build.sh](https://git.tronto.net/sebastiano.tronto.net/file/build.sh.html)
17script 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)
20function that takes care of building the index page and RSS feed for my blog.
21
22It is enough to add the following lines inside its main loop:
23
24```
25thisyear=$(echo $d | sed 's/-.*//')
26if [ "$thisyear" != "$lastyear" ]; then
27 printf "\n## $thisyear\n\n" >> $bf
28 lastyear=$thisyear
29fi
30```
31
32And that's it! These few lines introduce two new variables, `thisyear`
33and `lastyear`, that keep track of the years of the last and next blog
34post that the loop is scanning. If there was a year change, a new line
35with the current year is added, and the `lastyear` variable is updated.
36The first line refers to a variable `d` that holds the date of the
37current post in `yyyy-mm-dd` format.
38
39A last note on the variables: if you are familiar with other programming
40languages, you might wonder where the variable `lastyear` is initialized.
41After all, I am using it in the `if` statement's condition, so it must
42be initialized outside of its body, right?
43
44Actually, no. The shell's variable scoping does not work like in C or
45similar languages, and a variable initialized inside a block is also
46visibile outside of it. Moreover, un-initialized variables evaluate to
47the empty string, so the first time the condition is checked it correctly
48determines that the current year is different from the last.
49
50This was my last UNIX shell tip for this year. Stay tuned for more!
51
52![My netbook and planner for 2023](pc-planner.jpg)
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>

Generated with cgit - Back to sebastiano.tronto.net