✨ Add article thumb, cover and feature images
|
@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||
|
||||
### Added
|
||||
|
||||
- Support for article thumbnails, covers and featured images
|
||||
- Traditional Chinese (Taiwan) translation ([#262](https://github.com/jpanther/congo/pull/262))
|
||||
- New `list.paginationWidth` parameter to specify how many pagination links are generated before they are truncated
|
||||
- Tailwind plugin for Prettier to standardise the order of CSS classes ([#268](https://github.com/jpanther/congo/pull/268))
|
||||
|
|
|
@ -1799,6 +1799,14 @@ body:has(#menu-controller:checked) {
|
|||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.mb-6 {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.-mt-4 {
|
||||
margin-top: -1rem;
|
||||
}
|
||||
|
||||
.mr-3 {
|
||||
margin-right: 0.75rem;
|
||||
}
|
||||
|
@ -2240,6 +2248,10 @@ body:has(#menu-controller:checked) {
|
|||
padding-top: 0.75rem;
|
||||
}
|
||||
|
||||
.pr-4 {
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
||||
.pl-2 {
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
|
@ -2854,6 +2866,10 @@ body:has(#menu-controller:checked) {
|
|||
width: 50%;
|
||||
}
|
||||
|
||||
.sm\:w-40 {
|
||||
width: 10rem;
|
||||
}
|
||||
|
||||
.sm\:flex-row {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
@ -2872,6 +2888,10 @@ body:has(#menu-controller:checked) {
|
|||
padding-bottom: 2.5rem;
|
||||
}
|
||||
|
||||
.sm\:pr-6 {
|
||||
padding-right: 1.5rem;
|
||||
}
|
||||
|
||||
.sm\:pt-10 {
|
||||
padding-top: 2.5rem;
|
||||
}
|
||||
|
|
After Width: | Height: | Size: 44 KiB |
|
@ -89,6 +89,8 @@ Although these are the default schemes, you can also create your own. Refer to t
|
|||
|
||||
By default, Congo doesn't force you to use a particular content type. In doing so you are free to define your content as you wish. You might prefer _pages_ for a static site, _posts_ for a blog, or _projects_ for a portfolio.
|
||||
|
||||
### Directory structure
|
||||
|
||||
Here's a quick overview of a basic Congo project. All content is placed within the `content` folder:
|
||||
|
||||
```shell
|
||||
|
@ -111,8 +113,45 @@ Here's a quick overview of a basic Congo project. All content is placed within t
|
|||
└── congo
|
||||
```
|
||||
|
||||
{{< alert >}}
|
||||
The key thing to note here is that within the content directory, normal article pages are named `index.md` while list pages are named `_index.md`. Any assets that go along with the article should be placed in a sub-directory alongside the index file.
|
||||
{{< /alert >}}
|
||||
|
||||
It's important to have a firm grasp of how Hugo expects content to be organised as the theme is designed to take full advantage of Hugo page bundles. Be sure to read the [official Hugo docs](https://gohugo.io/content-management/organization/) for more information.
|
||||
|
||||
### Feature, cover and thumbnail images
|
||||
|
||||
The Congo theme supports displaying images on article listings and at the top of individual article pages. There are three types of images supported, each with their own use case: `feature`, `cover` and `thumb`.
|
||||
|
||||
In the example below, a cover and thumb image have been provided for the `first-post` article:
|
||||
|
||||
```shell
|
||||
.
|
||||
└── content
|
||||
└── posts
|
||||
├── _index.md
|
||||
└── first-post
|
||||
├── cover.jpg
|
||||
├── index.md
|
||||
└── thumb.jpg
|
||||
```
|
||||
|
||||
The `thumb` image is used as the article thumbnail and will be displayed in article lists, and the `cover` image will be displayed at the top of the article content on individual article pages.
|
||||
|
||||
![A screenshot of an article with a thumbnail image](article-screenshot.jpg "This example shows an article with a thumbnail image.")
|
||||
|
||||
{{< alert >}}
|
||||
In order to provide maximum performance, thumbnail images are automatically cropped and resized to a 4:3 ratio. Cover images will be automatically resized to fit their content, but any ratio is permitted.
|
||||
{{< /alert >}}
|
||||
|
||||
The `feature` image is a special type, and when present, it will be used in place of _both_ the `thumb` and `cover` images. Feature images are also present in the article metadata, which is included when content is shared to third-party networks like Facebook and Twitter.
|
||||
|
||||
The theme will intelligently detect article images and automatically add them to your site. You don't have to refer to them in the front matter and simply need to place an appropriately named file within the page resources. If the term `feature`, `cover` or `thumb` is found anywhere in the image filename, then it will be used for that purpose.
|
||||
|
||||
The [Samples section]({{< ref "samples" >}}) provides a number of examples of these images (and you can view the [source code](https://github.com/jpanther/congo/tree/dev/exampleSite/content/samples) to see the file structure).
|
||||
|
||||
### Taxonomies
|
||||
|
||||
Congo is also flexible when it comes to taxonomies. Some people prefer to use _tags_ and _categories_ to group their content, others prefer to use _topics_.
|
||||
|
||||
Hugo defaults to using posts, tags and categories out of the box and this will work fine if that's what you want. If you wish to customise this, however, you can do so by creating a `taxonomies.toml` configuration file:
|
After Width: | Height: | Size: 147 KiB |
After Width: | Height: | Size: 146 KiB |
After Width: | Height: | Size: 315 KiB |
|
@ -1,11 +1,11 @@
|
|||
---
|
||||
title: "An External Article"
|
||||
title: "External Article - Why I switched to Fathom Analytics"
|
||||
date: 2019-01-24
|
||||
externalUrl: "https://jamespanther.com/writings/i-switched-from-google-analytics-to-fathom-analytics/"
|
||||
summary: "The `externalUrl` front matter parameter can link to any URL."
|
||||
summary: "The `externalUrl` front matter parameter can link to any URL. This article looks just like any other, but will link to a post that is outside the Hugo project."
|
||||
showReadingTime: false
|
||||
_build:
|
||||
render: "false"
|
||||
render: "never"
|
||||
list: "local"
|
||||
---
|
||||
|
After Width: | Height: | Size: 253 KiB |
After Width: | Height: | Size: 145 KiB |
After Width: | Height: | Size: 438 KiB |
After Width: | Height: | Size: 433 KiB |
After Width: | Height: | Size: 148 KiB |
After Width: | Height: | Size: 128 KiB |
|
@ -1,4 +1,7 @@
|
|||
{{ define "main" }}
|
||||
{{- $images := .Resources.ByType "image" }}
|
||||
{{- $cover := $images.GetMatch "*cover*" }}
|
||||
{{- $feature := $images.GetMatch "*feature*" | default $cover }}
|
||||
<article>
|
||||
<header class="max-w-prose">
|
||||
{{ if .Params.showBreadcrumbs | default (.Site.Params.article.showBreadcrumbs | default false) }}
|
||||
|
@ -10,6 +13,17 @@
|
|||
<div class="mt-8 mb-12 text-base text-neutral-500 dark:text-neutral-400 print:hidden">
|
||||
{{ partial "article-meta.html" (dict "context" . "scope" "single") }}
|
||||
</div>
|
||||
{{ with $feature }}
|
||||
<img
|
||||
class="mb-6 -mt-4 rounded-md"
|
||||
srcset="
|
||||
{{- (.Resize "330x").RelPermalink }} 330w,
|
||||
{{- (.Resize "660x").RelPermalink }} 660w,
|
||||
{{- (.Resize "1024x").RelPermalink }} 1024w,
|
||||
{{- (.Resize "1320x").RelPermalink }} 2x"
|
||||
src="{{ (.Resize "660x").RelPermalink }}"
|
||||
/>
|
||||
{{ end }}
|
||||
</header>
|
||||
<section class="flex flex-col max-w-full mt-0 prose dark:prose-invert lg:flex-row">
|
||||
{{ if and (.Params.showTableOfContents | default (.Site.Params.article.showTableOfContents | default false)) (in .TableOfContents "<ul") }}
|
||||
|
|
|
@ -1,5 +1,28 @@
|
|||
<article>
|
||||
<h3 class="flex items-center mt-6 text-xl font-semibold">
|
||||
<article class="flex flex-row mt-6 max-w-prose">
|
||||
{{- $images := $.Resources.ByType "image" }}
|
||||
{{- $thumbnail := $images.GetMatch "*thumb*" }}
|
||||
{{- $feature := $images.GetMatch "*feature*" | default $thumbnail }}
|
||||
{{- with $feature }}
|
||||
<div class="flex-none pr-4 sm:pr-6 ">
|
||||
<a
|
||||
href="{{ with $.Params.externalUrl }}
|
||||
{{ . }}
|
||||
{{ else }}
|
||||
{{ $.RelPermalink }}
|
||||
{{ end }}"
|
||||
>
|
||||
<img
|
||||
class="w-24 rounded-md sm:w-40"
|
||||
srcset="
|
||||
{{- (.Fill "160x120 smart").RelPermalink }} 160w,
|
||||
{{- (.Fill "320x240 smart").RelPermalink }} 2x"
|
||||
src="{{ (.Fill "160x120 smart").RelPermalink }}"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
{{- end }}
|
||||
<div>
|
||||
<h3 class="flex items-center text-xl font-semibold">
|
||||
{{ with .Params.externalUrl }}
|
||||
<div>
|
||||
<a
|
||||
|
@ -41,4 +64,5 @@
|
|||
{{ .Summary | emojify }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</article>
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
{{ $meta.Add "partials" (slice (partial "meta/edit.html" .)) }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
<div class="flex flex-row flex-wrap items-center">
|
||||
{{/* Output partials */}}
|
||||
{{ with ($meta.Get "partials") }}
|
||||
|
|