From 55c5d52e5abf7efc2c33ec68159940db46139c14 Mon Sep 17 00:00:00 2001
From: Nicola Belluti <nicolabelluti@protonmail.com>
Date: Wed, 29 Jan 2025 10:58:05 +0100
Subject: [PATCH] [skip ci] Added the `cite_introduction_to_computing_systems`
 shortcode

---
 layouts/partials/cite_book.html               | 28 ++++++++++
 layouts/shortcodes/cite_book.html             | 54 ++++++++++---------
 ...ite_introduction_to_computing_systems.html | 53 ++++++++++++++++++
 3 files changed, 110 insertions(+), 25 deletions(-)
 create mode 100644 layouts/partials/cite_book.html
 create mode 100644 layouts/shortcodes/cite_introduction_to_computing_systems.html

diff --git a/layouts/partials/cite_book.html b/layouts/partials/cite_book.html
new file mode 100644
index 0000000..0f61165
--- /dev/null
+++ b/layouts/partials/cite_book.html
@@ -0,0 +1,28 @@
+{{/* See layouts/shortcodes/cite_book.html */}}
+
+<div style="display: inline">
+
+{{/* Authors */}}
+{{ with .author }}<b>{{ . }}</b>{{ end }}{{ with .author2 }}; <b>{{ . }}</b>{{ end }}
+
+{{/* Date */}}
+{{ with .date }}({{ . }}).{{ end }}
+
+{{/* Chapter */}}
+{{ with .chapter }}"{{ . }}"{{ end }}
+
+{{/* Title and edition */}}
+{{ with .title }}in <i>{{ . }}</i>{{ end }}
+{{ with .edition }}({{ . }} ed.){{ end }}.
+
+{{/* Publisher */}}
+{{ with .publisher }}{{ . }}.{{ end }}
+
+{{/* Pages */}}
+{{ with .page }}p. {{ . }}.{{ end }}
+{{ with .pages }}pp. {{ . }}.{{ end }}
+
+{{/* ISBN */}}
+{{ with .isbn }}ISBN {{ . }}.{{ end }}
+
+</div>
diff --git a/layouts/shortcodes/cite_book.html b/layouts/shortcodes/cite_book.html
index 4aa993e..a8c828c 100644
--- a/layouts/shortcodes/cite_book.html
+++ b/layouts/shortcodes/cite_book.html
@@ -3,30 +3,34 @@
 A template for citing books inspired by the "cite book" template of Wikipedia.
 <https://en.wikipedia.org/wiki/Template:Cite_book>
 
+### Example
+
+```md
+{{< cite_book
+  chapter = "1.2 How We Will Get There"
+  pages = "2-6"
+
+  title = "Introduction to Computing Systems – from Bits & Gates to C & Beyond"
+  edition = "1"
+  date = "2001"
+  publisher = "McGraw-Hill Higher Education"
+  isbn = "9780072376906"
+
+  author = "Patt, Yale N."
+  author2 = "Patel, Sanjay J."
+>}}
+```
+
 */}}
 
-<div style="display: inline">
-
-{{/* Authors */}}
-{{ with .Get "author" }}<b>{{ . }}</b>{{ end }}{{ with .Get "author2" }}; <b>{{ . }}</b>{{ end }}
-
-{{/* Date */}}
-{{ with .Get "date" }}({{ . }}).{{ end }}
-
-{{/* Chapter */}}
-{{ with .Get "chapter" }}"{{ . }}"{{ end }}
-
-{{/* Title and edition */}}
-{{ with .Get "title" }}in <i>{{ . }}</i>{{ end }}{{ with .Get "edition" }}({{ . }} ed.){{ end }}.
-
-{{/* Publisher */}}
-{{ with .Get "publisher" }}{{ . }}.{{ end }}
-
-{{/* Pages */}}
-{{ with .Get "page" }}p. {{ . }}.{{ end }}
-{{ with .Get "pages" }}pp. {{ . }}.{{ end }}
-
-{{/* ISBN */}}
-{{ with .Get "isbn" }}ISBN {{ . }}.{{ end }}
-
-</div>
+{{ partial "cite_book.html" (dict
+  "chapter" (.Get "chapter")
+  "pages" (.Get "pages")
+  "title" (.Get "title")
+  "edition" (.Get "edition")
+  "date" (.Get "date")
+  "publisher" (.Get "publisher")
+  "isbn" (.Get "isbn")
+  "author" (.Get "author")
+  "author2" (.Get "author2")
+) }}
diff --git a/layouts/shortcodes/cite_introduction_to_computing_systems.html b/layouts/shortcodes/cite_introduction_to_computing_systems.html
new file mode 100644
index 0000000..bfdc767
--- /dev/null
+++ b/layouts/shortcodes/cite_introduction_to_computing_systems.html
@@ -0,0 +1,53 @@
+{{/*
+
+Use the `cite_book` shortcode for "Introduction to Computing Systems"
+specifically
+
+### Example
+
+```md
+{{< cite_introduction_to_computing_systems
+  edition = "1"
+  chapter = "1.2 How We Will Get There"
+  pages = "2-6"
+>}}
+```
+
+*/}}
+
+{{ $title := "" }}
+{{ $edition := "" }}
+{{ $date := "" }}
+{{ $isbn := "" }}
+
+{{ if eq (.Get "edition") "1" }}
+  {{ $edition = "1" }}
+  {{ $title = "Introduction to Computing Systems – from Bits & Gates to C & Beyond" }}
+  {{ $date = "2001" }}
+  {{ $isbn = "9780072376906" }}
+{{ else if eq (.Get "edition") "2" }}
+  {{ $edition = "2" }}
+  {{ $title = "Introduction to Computing Systems – from Bits & Gates to C & Beyond" }}
+  {{ $date = "2004" }}
+  {{ $isbn = "9780072467505" }}
+{{ else }}
+  {{ $edition = "3" }}
+  {{ $title = "Introduction to Computing Systems – from Bits & Gates to C/C++ & Beyond" }}
+  {{ $date = "2019" }}
+  {{ $isbn = "9781260150537" }}
+{{ end }}
+
+{{ partial "cite_book.html" (dict
+  "chapter" (.Get "chapter")
+  "page" (.Get "page")
+  "pages" (.Get "pages")
+
+  "edition" $edition
+  "title" $title
+  "date" $date
+  "isbn" $isbn
+
+  "publisher" "McGraw-Hill Higher Education" 
+  "author" "Patt, Yale N."
+  "author2" "Patel, Sanjay J."
+) }}