[skip ci] Added the cite_introduction_to_computing_systems shortcode

This commit is contained in:
Nicola Belluti 2025-01-29 10:58:05 +01:00
parent 3df0d8d4d8
commit 55c5d52e5a
3 changed files with 110 additions and 25 deletions

View File

@ -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>

View File

@ -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")
) }}

View File

@ -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."
) }}