Skip to content

Commit

Permalink
Merge pull request #790 from nunocoracao/771-author-on-top-of-articles
Browse files Browse the repository at this point in the history
🎨 author on top of articles
  • Loading branch information
nunocoracao authored Jun 29, 2023
2 parents 9d8d050 + 7c6663c commit b643e6f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 56 deletions.
5 changes: 3 additions & 2 deletions exampleSite/content/users/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: "Some real-life Blowfish examples."
slug: "users"
tags: ["users", "sample"]
showDate: false
showAuthor: true
showAuthor: false
showReadingTime: false
showEdit: false
layoutBackgroundHeaderSpace: false
Expand Down Expand Up @@ -80,7 +80,8 @@ Real websites that are built with Blowfish.
| [blog.enmanuelmoreira.com](https://blog.enmanuelmoreira.com) | Personal site |
| [halcyonstraits.com](https://www.halcyonstraits.com/) | Doll photography |
| [50-nuances-octets.fr](https://www.50-nuances-octets.fr/) | Organization site |
| [marupanda.art/marucomics][https://marupanda.art/marucomics/] | Comics site |
| [marupanda.art/marucomics](https://marupanda.art/marucomics/) | Comics site |

{{< alert >}}

**Blowfish user?** To add your site to this list, [submit a pull request](https://github.com/nunocoracao/blowfish/blob/main/exampleSite/content/users/index.md).
Expand Down
60 changes: 35 additions & 25 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,40 @@ <h1 class="mt-0 text-4xl font-extrabold text-neutral-900 dark:text-neutral">
<div class="mt-1 mb-6 text-base text-neutral-500 dark:text-neutral-400 print:hidden">
{{ partial "article-meta/basic.html" (dict "context" . "scope" "single") }}
</div>

{{ $authorsData := .Site.Data.authors }}
{{ $taxonomies := .Site.Taxonomies.authors }}
{{ $baseURL := .Site.BaseURL }}
{{ $taxonomyLink := 0 }}
{{ $showAuthor := 0 }}

{{ if .Params.showAuthor | default (.Site.Params.article.showAuthor | default true) }}
{{ $showAuthor = 1 }}
{{ partial "author.html" . }}
{{ end }}

{{ if not (strings.HasSuffix $baseURL "/") }}
{{ $baseURL = delimit (slice $baseURL "/") "" }}
{{ end }}

{{ range $author := .Page.Params.authors }}
{{ $authorData := index $authorsData $author }}
{{- if $authorData -}}

{{ range $taxonomyname, $taxonomy := $taxonomies }}
{{ if (eq $taxonomyname $author) }}
{{ $taxonomyLink = delimit (slice $baseURL "/authors/" $author) "" }}
{{ end }}
{{ end }}

{{ partial "author-extra.html" (dict "context" . "data" $authorData "link" $taxonomyLink) }}
{{- end -}}
{{ end }}

{{ if or $taxonomyLink $showAuthor }}
<div class="mb-5"></div>
{{ end }}

</header>
<section class="flex flex-col max-w-full mt-0 prose dark:prose-invert lg:flex-row">
{{ if or (and (.Params.showTableOfContents | default (.Site.Params.article.showTableOfContents | default false)) (in
Expand Down Expand Up @@ -54,31 +88,7 @@ <h1 class="mt-0 text-4xl font-extrabold text-neutral-900 dark:text-neutral">
</section>
<footer class="pt-8 max-w-prose print:hidden">

{{ partial "author.html" . }}

{{ $authorsData := .Site.Data.authors }}
{{ $taxonomies := .Site.Taxonomies.authors }}
{{ $baseURL := .Site.BaseURL }}

{{ if not (strings.HasSuffix $baseURL "/") }}
{{ $baseURL = delimit (slice $baseURL "/") "" }}
{{ end }}

{{ range $author := .Page.Params.authors }}
{{ $authorData := index $authorsData $author }}
{{- if $authorData -}}

{{ $taxonomyLink := 0 }}
{{ range $taxonomyname, $taxonomy := $taxonomies }}
{{ if (eq $taxonomyname $author) }}
{{ $taxonomyLink = delimit (slice $baseURL "/authors/" $author) "" }}
{{ end }}
{{ end }}

{{ partial "author-extra.html" (dict "context" . "data" $authorData "link" $taxonomyLink) }}
{{- end -}}
{{ end }}


{{ partial "sharing-links.html" . }}

{{ partial "related.html" . }}
Expand Down
51 changes: 22 additions & 29 deletions layouts/partials/author.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
{{ if .Params.showAuthor | default (.Site.Params.article.showAuthor | default true) }}
<div class="flex">
{{ with .Site.Author.image }}
{{ $authorImage := resources.Get . }}
{{ if $authorImage }}
{{ $authorImage := $authorImage.Fill "192x192" }}
<img
class="!mt-0 !mb-0 h-24 w-24 rounded-full ltr:mr-4 rtl:ml-4"
width="96"
height="96"
alt="{{ $.Site.Author.name | default "Author" }}"
src="{{ $authorImage.RelPermalink }}"
/>
{{ end }}
{{ end }}
<div class="place-self-center">
{{ with .Site.Author.name | markdownify | emojify }}
<div class="text-[0.6rem] uppercase leading-3 text-neutral-500 dark:text-neutral-400">
{{ i18n "author.byline_title" | markdownify | emojify }}
</div>
<div class="font-semibold leading-6 text-neutral-800 dark:text-neutral-300">
{{ . }}
</div>
{{ end }}
{{ with .Site.Author.bio | markdownify | emojify }}
<div class="text-sm text-neutral-700 dark:text-neutral-400">{{ . }}</div>
{{ end }}
<div class="text-2xl sm:text-lg">{{ partialCached "author-links.html" . }}</div>
<div class="flex">
{{ with .Site.Author.image }}
{{ $authorImage := resources.Get . }}
{{ if $authorImage }}
{{ $authorImage := $authorImage.Fill "192x192" }}
<img class="!mt-0 !mb-0 h-24 w-24 rounded-full ltr:mr-4 rtl:ml-4" width="96" height="96"
alt="{{ $.Site.Author.name | default " Author" }}" src="{{ $authorImage.RelPermalink }}" />
{{ end }}
{{ end }}
<div class="place-self-center">
{{ with .Site.Author.name | markdownify | emojify }}
<div class="text-[0.6rem] uppercase leading-3 text-neutral-500 dark:text-neutral-400">
{{ i18n "author.byline_title" | markdownify | emojify }}
</div>
<div class="font-semibold leading-6 text-neutral-800 dark:text-neutral-300">
{{ . }}
</div>
{{ end }}
{{ with .Site.Author.bio | markdownify | emojify }}
<div class="text-sm text-neutral-700 dark:text-neutral-400">{{ . }}</div>
{{ end }}
<div class="text-2xl sm:text-lg">{{ partialCached "author-links.html" . }}</div>
</div>
{{ end }}
</div>

0 comments on commit b643e6f

Please sign in to comment.