mirror of https://github.com/lxndrblz/anatole.git

LucasVadilho
15.49.2020 725f02b285daea9c6cc01e70266434de16c7b355
Add support for thumbnail in the post preview

The thumbnail is inserted in the font matter via the param `thumbnail` which should contain the image source.

The style of the thumbnail is controlled by two css variables:

- `thumbnail-size`: default is 150px
- `thumbnail-position`: default is `1` which places it to the right, can be set to `-1` to place it to the left

Also updates some of the content post to show the effect.
2 files modified
38 ■■■■■ changed files
assets/css/style.css 29 ●●●●● patch | view | raw | blame | history
layouts/index.html 9 ●●●● patch | view | raw | blame | history
assets/css/style.css
@@ -12,6 +12,8 @@
    --tag-color: #424242;
    --blockquote-text-color: #858585;
    --blockquote-border-color: #dfe2e5;
    --thumbnail-size: 150px;
    --thumbnail-position: 1; /* -1 left, 1 right */
    scroll-padding-top: 100px;
}
@@ -323,7 +325,9 @@
}
.post {
    /* max-width: 720px; better for larger resolutions */
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    margin: 30px;
}
@@ -390,7 +394,6 @@
.post .post-footer {
    padding: 0 0 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.post .post-footer .meta {
@@ -461,6 +464,30 @@
    text-decoration: none;
}
/* Post preview */
.preview {
    display: flex;
    justify-content: space-between;
}
.preview .thumbnail {
    order: var(--thumbnail-position);
    height: var(--thumbnail-size);
    width: var(--thumbnail-size);
    flex: 0 0 auto;
    margin: 0 20px 20px 20px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--secondary-bg-color); /* for lazy loading */
}
.preview .thumbnail img {
    max-height: 100%;
}
.pagination {
    margin: 30px;
    padding: 0px 0 56px 0;
layouts/index.html
@@ -1,7 +1,8 @@
{{ define "main" }}
    {{ $paginator := .Paginate (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) }}
    {{ range $paginator.Pages }}
        <div class="post animated fadeInDown">
        <div class="post animated fadeInDown preview">
            <div class="post-text">
            <div class="post-title">
                <h3><a href="{{ .RelPermalink }}">{{ .Title }}</a>
                </h3>
@@ -25,6 +26,12 @@
                </div>
            </div>
        </div>
            {{ if isset .Params "thumbnail" }}
            <div class="thumbnail">
                <img src="{{ .Params.thumbnail | absURL }}" loading="lazy">
            </div>
            {{ end }}
        </div>
    {{ end }}
    <div class="pagination">
        {{ template "_internal/pagination.html" . }}