mirror of
https://github.com/gcushen/hugo-academic.git
synced 2025-07-26 03:00:50 +02:00
posts widget: Add tags
option
Allow to limit post list to posts containing specified tags.
This commit is contained in:
parent
be4fd472dd
commit
b51cc00c56
5 changed files with 46 additions and 30 deletions
|
@ -12,6 +12,9 @@ widget = "posts"
|
|||
# Order that this section will appear in.
|
||||
weight = 30
|
||||
|
||||
# Show posts that contain the following tags. Default to any tags.
|
||||
tags = []
|
||||
|
||||
# Number of posts to list.
|
||||
count = 5
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ Key features:
|
|||
- Responsive and mobile friendly
|
||||
- Simple and refreshing one page design
|
||||
- Easy to customize
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Installation
|
||||
|
@ -54,7 +55,7 @@ Assuming you created a new website with the example content following the instal
|
|||
|
||||
The core parameters for the website can be edited in the `config.toml` configuration file:
|
||||
|
||||
- Set `baseurl` to your website URL (we recommend [GitHub Pages](https://pages.github.com/) for free hosting)
|
||||
- Set `baseurl` to your website URL (we recommend [GitHub Pages](https://georgecushen.com/create-your-website-with-hugo/) for free hosting)
|
||||
- Set `title` to your desired website title such as your name
|
||||
- The example Disqus commenting variable should be cleared (e.g. `disqusShortname = ""`) or set to your own [Disqus](https://disqus.com/) shortname to enable commenting
|
||||
- Edit your details under `[params]`; these will be displayed mainly in the homepage *about* and *contact* widgets (if used). To disable a contact field, simply clear the value to `""`.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
+++
|
||||
date = "2014-03-10T00:00:00"
|
||||
draft = false
|
||||
tags = []
|
||||
tags = ["jekyll"]
|
||||
title = "Migrate from Jekyll to Hugo"
|
||||
summary = """
|
||||
Learn how to migrate an existing website from Jekyll to Hugo.
|
||||
|
|
29
layouts/partials/post_li.html
Normal file
29
layouts/partials/post_li.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
{{ $post := .post }}
|
||||
{{ $page := .page }}
|
||||
|
||||
<div class="article-list-item" itemscope itemprop="blogPost">
|
||||
{{ if $post.Params.image }}
|
||||
<a href="{{ .Permalink }}">
|
||||
<img src="{{ "/img/" | relURL }}{{ $post.Params.image }}" class="article-banner"
|
||||
itemprop="image">
|
||||
</a>
|
||||
{{end}}
|
||||
<h3 class="article-title" itemprop="name">
|
||||
<a href="{{ $post.Permalink }}" itemprop="url">{{ $post.Title }}</a>
|
||||
</h3>
|
||||
{{ partial "article_metadata" (dict "content" $post "is_list" 1) }}
|
||||
<p class="article-style" itemprop="articleBody">
|
||||
{{ if $post.Params.summary }}
|
||||
{{ printf "%s" $post.Params.summary | markdownify }}
|
||||
{{ else if $post.Truncated }}
|
||||
{{ $post.Summary }}
|
||||
{{ else }}
|
||||
{{ $post.Content }}
|
||||
{{ end }}
|
||||
</p>
|
||||
<p class="read-more">
|
||||
<a href="{{ $post.Permalink }}" class="btn btn-primary btn-outline">
|
||||
{{ with $page.Params.str_read_more }}{{ . | markdownify }}{{ end }}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
|
@ -23,37 +23,20 @@
|
|||
<div class="col-xs-12 col-md-8">
|
||||
{{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}
|
||||
|
||||
{{ range first $page.Params.count (where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil) }}
|
||||
<div class="article-list-item" itemscope itemprop="blogPost">
|
||||
{{ if .Params.image }}
|
||||
<a href="{{ .Permalink }}">
|
||||
<img src="{{ "/img/" | relURL }}{{ .Params.image }}" class="article-banner"
|
||||
itemprop="image">
|
||||
</a>
|
||||
{{end}}
|
||||
<h3 class="article-title" itemprop="name">
|
||||
<a href="{{ .Permalink }}" itemprop="url">{{.Title }}</a>
|
||||
</h3>
|
||||
{{ partial "article_metadata" (dict "content" . "is_list" 1) }}
|
||||
<p class="article-style" itemprop="articleBody">
|
||||
{{ if .Params.summary }}
|
||||
{{ printf "%s" .Params.summary | markdownify }}
|
||||
{{ else if .Truncated }}
|
||||
{{ printf "%s" .Summary | markdownify }}
|
||||
{{ else }}
|
||||
{{ .Content }}
|
||||
{{ end }}
|
||||
</p>
|
||||
<p class="read-more">
|
||||
<a href="{{ .Permalink }}" class="btn btn-primary btn-outline">
|
||||
{{ with $page.Params.str_read_more }}{{ . | markdownify }}{{ end }}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
{{ if $page.Params.tags }}
|
||||
{{ range first $page.Params.count (where (where (where $.Data.Pages "Type" "post") ".Params.tags" "intersect" $page.Params.tags) ".Params.notonhomepage" nil) }}
|
||||
{{ $params := dict "post" . "page" $page }}
|
||||
{{ partial "post_li" $params }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ range first $page.Params.count (where (where $.Data.Pages "Type" "post") ".Params.notonhomepage" nil) }}
|
||||
{{ $params := dict "post" . "page" $page }}
|
||||
{{ partial "post_li" $params }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue