From ab3d2d785758aebf0da5a59c3aed6a172a71f59d Mon Sep 17 00:00:00 2001 From: Francesco Date: Fri, 16 May 2025 19:34:51 +0200 Subject: Add author rendering --- assets/css/main.css | 25 +++++++++++++++++++-- layouts/_default/single.html | 40 ++++++++++++++++++++------------- wiki/features/single-page-parameters.md | 10 +++++++++ wiki/setup.md | 2 ++ 4 files changed, 60 insertions(+), 17 deletions(-) diff --git a/assets/css/main.css b/assets/css/main.css index 300bc16..9c4b39e 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -329,8 +329,28 @@ footer a { margin-bottom: .5rem; } -.single-readtime { - margin-top: .5rem; +.single-subsummary { + margin-top: calc(.8 * var(--p-margin-top)); + margin-bottom: var(--p-margin-bottom); + display: flex; + align-items: center; +} + +.single-subsummary img { + height: 45px; + width: 45px; + margin-right: .7rem; + border-radius: 50%; +} + +.author { + margin-bottom: 0; + margin-top: 0; +} + +.single-date { + margin-top: 0; + margin-bottom: 0; color: var(--content-secondary); } @@ -351,6 +371,7 @@ footer a { margin-right: .3rem; } + /* Single pagination */ .single-pagination { diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 209524e..01c35c2 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -15,21 +15,31 @@ {{- with .Param "summary" }}

{{ . | markdownify }}

{{- end }} - - {{- /* Reading Time */}} - -

- {{- with .Date }} - {{- $dateMachine := . | time.Format "2006-01-02T15:04:05-07:00" }} - {{- $dateHuman := . | time.Format (default ":date_long" $.Site.Params.singleDateFormat) }} - - {{- end }} - - {{- if .Param "readTime" }} -   ·   - {{- .ReadingTime }} min read - {{- end }} -

+ + {{- /* Date, Reading Time and Author */}} +
+ {{ with $.Param "authorAvatarPath" }} + Author Avatar + {{ end }} +
+ {{ with .Param "author" }} +

{{- .}}

+ {{ end }} +

+ {{- with .Date }} + {{- $dateMachine := . | time.Format "2006-01-02T15:04:05-07:00" }} + {{- $dateHuman := . | time.Format (default ":date_long" $.Site.Params.singleDateFormat) }} + + {{- end }} + + {{- if .Param "readTime" }} +   ·   + {{- .ReadingTime }} min read + {{- end }} +

+
+
+ {{- if .Param "showTags" }} diff --git a/wiki/features/single-page-parameters.md b/wiki/features/single-page-parameters.md index 0bf62b0..8ebb3c6 100644 --- a/wiki/features/single-page-parameters.md +++ b/wiki/features/single-page-parameters.md @@ -12,6 +12,16 @@ showTags: false The following parameters apply to single pages, they are meant to be inserted in the `.md` files introductions, apart from the date format. +## Author + +You can specify an author name to display and avatar path to use. Here is an example +using an image from /static: + +```md +author: "Francesco" +authorAvatarPath: "/avatar.jpeg" +``` + ## Table of Contents Show a table of contents at the beginning of the post. diff --git a/wiki/setup.md b/wiki/setup.md index ef17db8..b93f21d 100644 --- a/wiki/setup.md +++ b/wiki/setup.md @@ -169,6 +169,8 @@ Sample post config. ```markdown --- title: "Log-Structured Merge Tree" +author: "Francesco" +authorAvatarPath: "/avatar.jpeg" date: "2023-11-12" summary: "An LSM Tree overview and Java implementation." description: "An LSM Tree overview and Java implementation." -- cgit v1.2.3