mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 22:14:08 +00:00
refactor: consolidate and simplify card views
- Consolidate the code for all card views into a single file - `continue_reading` removed from i18n See #918
This commit is contained in:
1 parent
1dc9c8d197
commit
3944d35633
16 files changed
+101
-131
No files matched your search
@@ -95,9 +95,6 @@
|
||||
|
||||
# Posts widget
|
||||
|
||||
- id: continue_reading
|
||||
translation: CONTINUE READING
|
||||
|
||||
- id: more_posts
|
||||
translation: See all posts
|
||||
|
||||
|
||||
@@ -1043,11 +1043,13 @@ article .article-metadata {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.media.stream-item .article-title {
|
||||
.media.stream-item .article-title,
|
||||
.card-simple .article-title {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.media.stream-item .article-style {
|
||||
.media.stream-item .article-style,
|
||||
.card-simple .article-style {
|
||||
margin-top: 2px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
{{ $item := . }}
|
||||
|
||||
{{ $microdata_type := "CreativeWork" }}
|
||||
{{ $show_buttons := false }}
|
||||
|
||||
{{/* Dynamic view adjusts to content type. */}}
|
||||
{{ if eq $item.Type "post" }}
|
||||
{{ $microdata_type = "BlogPosting" }}
|
||||
{{ else if eq $item.Type "talk" }}
|
||||
{{ $microdata_type = "Event" }}
|
||||
{{ $show_buttons = true }}
|
||||
{{ else if eq $item.Type "publication" }}
|
||||
{{ $microdata_type = "ScholarlyArticle" }}
|
||||
{{ $show_buttons = true }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Get summary. */}}
|
||||
{{ $summary := "" }}
|
||||
{{ if $item.Params.summary }}
|
||||
{{ $summary = $item.Params.summary | markdownify | emojify }}
|
||||
{{ else if .Params.abstract }}
|
||||
{{ $summary = .Params.abstract | markdownify | emojify }}
|
||||
{{ else if $item.Truncated }}
|
||||
{{ $summary = $item.Summary }}
|
||||
{{ else }}
|
||||
{{ $summary = $item.Content }}
|
||||
{{ end }}
|
||||
|
||||
<div class="card-simple" itemscope itemtype="http://schema.org/{{$microdata_type}}">
|
||||
|
||||
{{ if eq $item.Type "talk" }}
|
||||
<div class="article-metadata">
|
||||
{{ if $item.Params.authors }}
|
||||
<div itemprop="author">
|
||||
{{ partial "page_metadata_authors" $item }}
|
||||
</div>
|
||||
{{ end }}
|
||||
<span itemprop="startDate">
|
||||
{{ $date := $item.Params.time_start | default $item.Date }}
|
||||
{{ (time $date).Format $.Site.Params.date_format }}
|
||||
{{ if not $item.Params.all_day }}
|
||||
{{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
|
||||
{{ with .Params.time_end }}
|
||||
— {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</span>
|
||||
{{ with $item.Params.location }}
|
||||
<span class="middot-divider"></span>
|
||||
<span itemprop="location">{{ . }}</span>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ else }}
|
||||
{{ partial "page_metadata" (dict "content" $item "is_list" 1) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }}
|
||||
{{ $anchor := $item.Params.image.focal_point | default "Smart" }}
|
||||
{{ with $resource }}
|
||||
{{ $image := .Fill (printf "918x517 q90 %s" $anchor) }}
|
||||
<a href="{{ $item.RelPermalink }}">
|
||||
<img src="{{ $image.RelPermalink }}" class="article-banner" itemprop="image" alt="">
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<h3 class="article-title mb-1 mt-3" itemprop="name">
|
||||
<a href="{{ $item.RelPermalink }}" itemprop="url">{{ $item.Title }}</a>
|
||||
</h3>
|
||||
|
||||
{{ with $summary }}
|
||||
<div class="article-style" itemprop="articleBody">
|
||||
{{ . }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ if $show_buttons }}
|
||||
<div class="btn-links">
|
||||
{{ partial "page_links" (dict "content" $item "is_list" 1) }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
File renamed without changes.
@@ -1,31 +0,0 @@
|
||||
{{ $post := . }}
|
||||
|
||||
<div class="card-simple" itemscope itemprop="blogPost" itemtype="http://schema.org/BlogPosting">
|
||||
{{ partial "page_metadata" (dict "content" $post "is_list" 1) }}
|
||||
|
||||
{{ $resource := ($post.Resources.ByType "image").GetMatch "*featured*" }}
|
||||
{{ $anchor := $post.Params.image.focal_point | default "Smart" }}
|
||||
{{ with $resource }}
|
||||
{{ $image := .Fill (printf "918x517 q90 %s" $anchor) }}
|
||||
<a href="{{ $post.RelPermalink }}">
|
||||
<img src="{{ $image.RelPermalink }}" class="article-banner" itemprop="image" alt="">
|
||||
</a>
|
||||
{{end}}
|
||||
<h3 class="article-title" itemprop="headline">
|
||||
<a href="{{ $post.RelPermalink }}" itemprop="url">{{ $post.Title }}</a>
|
||||
</h3>
|
||||
<div class="article-style" itemprop="articleBody">
|
||||
{{ if $post.Params.summary }}
|
||||
<p>{{ printf "%s" $post.Params.summary | markdownify }}</p>
|
||||
{{ else if $post.Truncated }}
|
||||
{{ $post.Summary }}
|
||||
{{ else }}
|
||||
{{ $post.Content }}
|
||||
{{ end }}
|
||||
</div>
|
||||
<p class="read-more" itemprop="mainEntityOfPage">
|
||||
<a href="{{ $post.RelPermalink }}" class="btn btn-outline-primary my-1">
|
||||
{{ i18n "continue_reading" }}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
@@ -1,31 +0,0 @@
|
||||
<div class="pub-list-item card-simple" itemscope itemtype="http://schema.org/CreativeWork">
|
||||
{{ partial "page_metadata" (dict "content" $ "is_list" 1) }}
|
||||
|
||||
{{ $resource := (.Resources.ByType "image").GetMatch "*featured*" }}
|
||||
{{ $anchor := .Params.image.focal_point | default "Smart" }}
|
||||
{{ with $resource }}
|
||||
{{ $image := .Fill (printf "918x517 q90 %s" $anchor) }}
|
||||
<div>
|
||||
<a href="{{ $.RelPermalink }}">
|
||||
<img src="{{ $image.RelPermalink }}" class="article-banner" itemprop="image" alt="">
|
||||
</a>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<h3 class="article-title" itemprop="name">
|
||||
<a href="{{ .RelPermalink }}" itemprop="url">{{ .Title }}</a>
|
||||
</h3>
|
||||
|
||||
<div class="pub-abstract" itemprop="text">
|
||||
{{ if .Params.abstract_short }}
|
||||
{{ .Params.abstract_short | markdownify }}
|
||||
{{ else }}
|
||||
{{ .Params.abstract | markdownify}}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="btn-links">
|
||||
{{ partial "page_links" (dict "content" . "is_list" 1) }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -1,49 +0,0 @@
|
||||
<div class="card-simple" itemscope itemtype="http://schema.org/Event">
|
||||
|
||||
{{ $resource := (.Resources.ByType "image").GetMatch "*featured*" }}
|
||||
{{ $anchor := .Params.image.focal_point | default "Smart" }}
|
||||
{{ with $resource }}
|
||||
{{ $image := .Fill (printf "918x517 q90 %s" $anchor) }}
|
||||
<div>
|
||||
<a href="{{ $.RelPermalink }}">
|
||||
<img src="{{ $image.RelPermalink }}" class="article-banner" itemprop="image" alt="">
|
||||
</a>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<h3 class="article-title" itemprop="name">
|
||||
<a href="{{ .RelPermalink }}" itemprop="url">{{ .Title }}</a>
|
||||
</h3>
|
||||
|
||||
<div class="talk-metadata" itemprop="startDate">
|
||||
{{ $date := .Params.time_start | default .Date }}
|
||||
{{ (time $date).Format $.Site.Params.date_format }}
|
||||
{{ if not .Params.all_day }}
|
||||
{{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
|
||||
{{ with .Params.time_end }}
|
||||
— {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="talk-metadata">
|
||||
{{ if .Params.event }}
|
||||
{{ .Params.event | markdownify }}
|
||||
{{ else if .Params.event_short }}
|
||||
{{ .Params.event_short | markdownify }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="talk-abstract" itemprop="text">
|
||||
{{ if .Params.abstract_short }}
|
||||
{{ .Params.abstract_short | markdownify }}
|
||||
{{ else }}
|
||||
{{ .Params.abstract | markdownify }}
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div class="btn-links">
|
||||
{{ partial "page_links" (dict "content" . "is_list" 1) }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -29,7 +29,7 @@
|
||||
{{ if eq $page.Params.view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $page.Params.view 3 }}
|
||||
{{ partial "post_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
{{ if eq $page.Params.view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $page.Params.view 3 }}
|
||||
{{ partial "publication_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else if eq $page.Params.view 4 }}
|
||||
{{ partial "publication_li_citation" . }}
|
||||
{{ partial "li_citation" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
{{ if eq $page.Params.view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $page.Params.view 3 }}
|
||||
{{ partial "publication_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else if eq $page.Params.view 4 }}
|
||||
{{ partial "publication_li_citation" . }}
|
||||
{{ partial "li_citation" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
{{ if eq $page.Params.view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $page.Params.view 3 }}
|
||||
{{ partial "talk_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{{ if eq $page.Params.view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $page.Params.view 3 }}
|
||||
{{ partial "talk_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
{{ if eq $page.Site.Params.projects.post_view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $page.Site.Params.projects.post_view 3 }}
|
||||
{{ partial "post_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
@@ -40,9 +40,9 @@
|
||||
{{ if eq $page.Site.Params.projects.publication_view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $page.Site.Params.projects.publication_view 3 }}
|
||||
{{ partial "publication_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else if eq $page.Site.Params.projects.publication_view 4 }}
|
||||
{{ partial "publication_li_citation" . }}
|
||||
{{ partial "li_citation" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
@@ -57,7 +57,7 @@
|
||||
{{ if eq $page.Site.Params.projects.talk_view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $page.Site.Params.projects.talk_view 3 }}
|
||||
{{ partial "talk_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{{ if eq $.Params.view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $.Params.view 3 }}
|
||||
{{ partial "post_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -62,9 +62,9 @@
|
||||
{{ if eq $.Params.view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $.Params.view 3 }}
|
||||
{{ partial "publication_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else if eq $.Params.view 4 }}
|
||||
{{ partial "publication_li_citation" . }}
|
||||
{{ partial "li_citation" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
{{ if eq $.Params.view 1 }}
|
||||
{{ partial "li_list" . }}
|
||||
{{ else if eq $.Params.view 3 }}
|
||||
{{ partial "talk_li_card" . }}
|
||||
{{ partial "li_card" . }}
|
||||
{{ else }}
|
||||
{{ partial "li_compact" . }}
|
||||
{{ end }}
|
||||
|
||||
Reference in new issue
Block a user