Skip to content

Commit

Permalink
Merge pull request #12 from bigbrozer/patches/ci
Browse files Browse the repository at this point in the history
Implement previous / next on posts
  • Loading branch information
bigbrozer authored Sep 10, 2023
2 parents b8734a9 + 98a9cba commit 3e29083
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 46 deletions.
13 changes: 10 additions & 3 deletions .release-it.json → .release-it.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
const fs = require('fs');

const commitTemplate = fs.readFileSync('.release-it/commit.hbs').toString();

module.exports = {
"hooks": {
"after:bump": "make VERSION=${version} dist"
"after:git:release": "make VERSION=${version} dist"
},
"git": {
"commitMessage": "chore: release v${version}"
Expand All @@ -17,7 +21,10 @@
"@release-it/conventional-changelog": {
"preset": "conventionalcommits",
"infile": "CHANGELOG.md",
"header": "# Changelog"
"header": "# Changelog",
"writerOpts": {
"commitPartial": commitTemplate
}
},
"@j-ulrich/release-it-regex-bumper": {
"out": [
Expand Down
57 changes: 57 additions & 0 deletions .release-it/commit.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
* {{header}}

{{~!-- commit link --}}
{{~#if @root.linkReferences}} ([{{hash}}](
{{~#if @root.repository}}
{{~#if @root.host}}
{{~@root.host}}/
{{~/if}}
{{~#if @root.owner}}
{{~@root.owner}}/
{{~/if}}
{{~@root.repository}}
{{~else}}
{{~@root.repoUrl}}
{{~/if}}/
{{~@root.commit}}/{{hash}}))
{{~else if hash}} {{hash}}{{~/if}}

{{~!-- commit references --}}
{{~#if references~}}
, closes
{{~#each references}} {{#if @root.linkReferences~}}
[
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}#{{this.issue}}](
{{~#if @root.repository}}
{{~#if @root.host}}
{{~@root.host}}/
{{~/if}}
{{~#if this.repository}}
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}
{{~else}}
{{~#if @root.owner}}
{{~@root.owner}}/
{{~/if}}
{{~@root.repository}}
{{~/if}}
{{~else}}
{{~@root.repoUrl}}
{{~/if}}/
{{~@root.issue}}/{{this.issue}})
{{~else}}
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}#{{this.issue}}
{{~/if}}{{/each}}
{{~/if}}
\n
{{#if body}}
{{body}}
{{/if}}
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Contents:
* [Adding a post index page](#adding-a-post-index-page)
* [Theme settings](#theme-settings)
* [Acknowledgements](#acknowledgements)
* [Updates](#updates)
* [Updating from v0.2.0](#updating-from-v020)
* [License](#license)

## Getting Started
Expand All @@ -27,13 +29,13 @@ Once the theme is installed, read following sections to know how to use and conf

### Adding a portfolio image

The portfolio (on homepage) is composed of posts with only a `title`, a `featured image` and ensure `Other options ➔ Post template ➔ Image for the portfolio` is set.
The portfolio (on homepage) is composed of posts with only a `title`, a `featured image`, has `Status ➔ Hide Post` set to true and ensure `Other options ➔ Post template ➔ Image for the portfolio` is set.

This combination will show the picture with a lightbox effect. The `title` is used as the image caption.

### Adding a post index page

To generate a post index page where you can list all available posts, create a new post with a title like **Post index**, hide it and tag it `post-index`.
To generate a post index page where you can list all available posts, create a new post with a title like **Post index**, select `Status ➔ Hide Post`, tag it as `post-index` and ensure you use template `Other options ➔ Post template ➔ Show the index of all posts`.

You will see a link appearing below the **Readings** section from homepage to access the post index page.

Expand All @@ -48,6 +50,15 @@ From Publii, navigate to `Theme ➔ Custom settings` to customize the theme beha
* [UIKit](https://getuikit.com/) -- UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.
* [Release It!](https://github.com/release-it/release-it) -- Generic CLI tool to automate versioning and package publishing-related tasks.

## Updates

As this is a pre-release (below v1.x), sometime the theme will need some adaptations when upgrading. Follow the guide !

### Updating from v0.2.0

* In **Theme** menu on the left, enter the **Custom settings** area and set `Sidebar ➔ Number of posts: 2`. Save settings.
* From this release, you must hide all portfolio posts by enabling `Status ➔ Hide Post` in order to show them on the homepage.

## License

See [LICENSE](./LICENSE).
2 changes: 1 addition & 1 deletion assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ VARIABLE OVERRIDES
$global-font-size: 18px !default;
$global-background: #000000 !default;
$global-color: #f626eed9 !default;
$global-emphasis-color: #f626eed9 !default;
$global-emphasis-color: #ff54f9d9 !default;
$global-font-family: "Acme", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
$global-secondary-background: #691066d9 !default;
$navbar-background: #000 !default;
Expand Down
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{
"name": "postsPerPage",
"label": "Posts per page",
"value": 12,
"value": -1,
"type": "number"
},
{
Expand Down Expand Up @@ -106,7 +106,7 @@
"name": "amountSelectedtPosts",
"label": "Number of posts",
"group": "Sidebar",
"value": "3",
"value": "2",
"type": "text"
},
{
Expand Down
8 changes: 4 additions & 4 deletions index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
>
<h2 class="uk-heading-divider uk-text-center">Portfolio</h2>

{{> portfolio}}
{{> portfolio posts=@website.contentStructure.posts}}
</div>
</div>
{{! /Portfolio }}

{{! Posts }}
{{! Featured posts }}
<div class="uk-section uk-padding-small">
<a id="readings"></a>

<div class="uk-container uk-dark" uk-scrollspy="cls: uk-animation-slide-right">
<h2 class="uk-heading-divider uk-text-center">Readings</h2>
<h2 class="uk-heading-divider uk-text-center">Featured readings</h2>
{{> readings posts=posts featuredOnly=true }}
{{#getPostByTags "post-index" ""}}
<div class="uk-margin uk-flex uk-flex-right">
Expand All @@ -35,7 +35,7 @@
{{/getPostByTags}}
</div>
</div>
{{! /Posts }}
{{! /Featured posts }}

{{! Hero }}
<div
Expand Down
4 changes: 2 additions & 2 deletions partials/portfolio.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
uk-lightbox="animation: slide"
>
{{#each posts}}
{{#unless isHidden}}
{{#if isHidden}}
{{#checkIf template "==" "portfolio"}}
<div uk-scrollspy="cls: uk-animation-fade">
<a
Expand All @@ -23,6 +23,6 @@
</a>
</div>
{{/checkIf}}
{{/unless}}
{{/if}}
{{/each}}
</div>
43 changes: 11 additions & 32 deletions post.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
{{! main tag - if not selected, the first tag in the list of all tags will be displayed }}
{{#if mainTag}}
{{ translate 'post.mainTag' }}
<a href="{{ mainTag.url }}">
{{!-- <a href="{{ mainTag.url }}"> --}}
{{mainTag.name }}.
</a>
{{!-- </a> --}}
{{/if}}
{{! /main tag }}
</div>
Expand Down Expand Up @@ -107,34 +107,6 @@
{{{text}}}
</p>
{{! /post body }}

{{! previous & next post }}
{{! checks if there are any posts besides the current one; including ../ segment on a path, we change the post context into the parent context }}
{{#checkIfAny ../previousPost ../nextPost}}
{{!-- #TODO: use a navbar (left, right) --}}
<nav id="post-navigation">
{{#../previousPost}}
{{#checkIf template '!=' "portfolio"}}
<a class="uk-button uk-button-text" href="{{url}}" rel="prev">
&larr; {{ translate 'post.previousPost' }}
({{title}})
</a>
{{/checkIf}}
{{/../previousPost}}

{{#../nextPost}}
{{#checkIf template '!=' "portfolio"}}
<a class="uk-button uk-button-text" href="{{url}}" rel="next">
{{ translate 'post.nextPost' }}
({{title}}) &rarr;
</a>
{{/checkIf}}
{{/../nextPost}}
</nav>
{{/checkIfAny}}
{{! /checks if there are any posts besides the current one }}
{{! /previous & next post }}

</article>
{{/post}}

Expand All @@ -155,8 +127,15 @@

<div class="uk-section">
<div class="uk-container uk-dark" uk-scrollspy="cls: uk-animation-slide-right">
<h2 class="uk-heading-divider uk-text-center">Readings</h2>
{{> readings posts=@website.contentStructure.posts featuredOnly=true}}
<h2 class="uk-heading-divider uk-text-center">Continue reading</h2>
<div class="uk-grid-small uk-child-width-1-2@m" uk-grid="masonry: true">
{{#previousPost}}
<div>{{> post-card post=. }}</div>
{{/previousPost}}
{{#nextPost}}
<div>{{> post-card post=. }}</div>
{{/nextPost}}
</div>
</div>
</div>

Expand Down

0 comments on commit 3e29083

Please sign in to comment.