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 */}} + +
+ +{{/* Authors */}} +{{ with .author }}{{ . }}{{ end }}{{ with .author2 }}; {{ . }}{{ end }} + +{{/* Date */}} +{{ with .date }}({{ . }}).{{ end }} + +{{/* Chapter */}} +{{ with .chapter }}"{{ . }}"{{ end }} + +{{/* Title and edition */}} +{{ with .title }}in {{ . }}{{ end }} +{{ with .edition }}({{ . }} ed.){{ end }}. + +{{/* Publisher */}} +{{ with .publisher }}{{ . }}.{{ end }} + +{{/* Pages */}} +{{ with .page }}p. {{ . }}.{{ end }} +{{ with .pages }}pp. {{ . }}.{{ end }} + +{{/* ISBN */}} +{{ with .isbn }}ISBN {{ . }}.{{ end }} + +
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. +### 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." +>}} +``` + */}} -
- -{{/* Authors */}} -{{ with .Get "author" }}{{ . }}{{ end }}{{ with .Get "author2" }}; {{ . }}{{ end }} - -{{/* Date */}} -{{ with .Get "date" }}({{ . }}).{{ end }} - -{{/* Chapter */}} -{{ with .Get "chapter" }}"{{ . }}"{{ end }} - -{{/* Title and edition */}} -{{ with .Get "title" }}in {{ . }}{{ 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 }} - -
+{{ 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." +) }}