From 03642a1bc36f0ffa86e6a04f77539b8dbb9a3335 Mon Sep 17 00:00:00 2001 From: Ghyslain Leclerc Date: Wed, 29 Nov 2017 16:50:45 -0500 Subject: [PATCH 1/2] Add capacity to get yearly grouping for microposts. Adds a parameter called YearlyMicroposts which is used to either: - output the usual list of microposts if the parameter is not set or set to false; - output a list of micropost titles grouped by year (just like the posts list is) if the parameter is set and true. The default behavior is not changed and the setting needs not be defined thus not complicating the default installation. --- layouts/_default/list.html | 4 +--- layouts/partials/default_list.html | 3 +++ layouts/partials/yearly_grouping.html | 25 +++++++++++++++++++++++++ layouts/section/microposts.html | 15 +++++++++++++++ layouts/section/posts.html | 26 +------------------------- 5 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 layouts/partials/default_list.html create mode 100644 layouts/partials/yearly_grouping.html create mode 100644 layouts/section/microposts.html diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 20ca950..2e128cf 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,9 +1,7 @@ {{ partial "site_header.html" . }} {{ partial "page_header.html" . }} -
- {{ partial "preview_list.html" . }} -
+{{ partial "default_list.html" . }} {{ partial "page_footer.html" . }} {{ partial "site_footer.html" . }} diff --git a/layouts/partials/default_list.html b/layouts/partials/default_list.html new file mode 100644 index 0000000..142274c --- /dev/null +++ b/layouts/partials/default_list.html @@ -0,0 +1,3 @@ +
+ {{ partial "preview_list.html" . }} +
diff --git a/layouts/partials/yearly_grouping.html b/layouts/partials/yearly_grouping.html new file mode 100644 index 0000000..0cccf9e --- /dev/null +++ b/layouts/partials/yearly_grouping.html @@ -0,0 +1,25 @@ +
+
+
+ {{ range .Data.Pages.GroupByDate "2006" }} +
+

{{ .Key }}

+ +
+ {{ end }} +
+
+
diff --git a/layouts/section/microposts.html b/layouts/section/microposts.html new file mode 100644 index 0000000..c825505 --- /dev/null +++ b/layouts/section/microposts.html @@ -0,0 +1,15 @@ +{{ partial "site_header.html" . }} +{{ partial "page_header.html" . }} + +{{ if isset .Site.Params "yearlymicroposts" | and ( .Site.Params.yearlymicroposts ) }} + +{{ partial "yearly_grouping.html" . }} + +{{ else }} + +{{ partial "default_list.html" . }} + +{{ end }} + +{{ partial "page_footer.html" . }} +{{ partial "site_footer.html" . }} \ No newline at end of file diff --git a/layouts/section/posts.html b/layouts/section/posts.html index aca6cfa..24510ab 100644 --- a/layouts/section/posts.html +++ b/layouts/section/posts.html @@ -1,31 +1,7 @@ {{ partial "site_header.html" . }} {{ partial "page_header.html" . }} -
-
-
- {{ range .Data.Pages.GroupByDate "2006" }} -
-

{{ .Key }}

- -
- {{ end }} -
-
-
+{{ partial "yearly_grouping.html" . }} {{ partial "page_footer.html" . }} {{ partial "site_footer.html" . }} From 6a826bd4b78ba390393494376245e68711570c11 Mon Sep 17 00:00:00 2001 From: Ghyslain Leclerc Date: Fri, 19 Jan 2018 12:08:23 -0500 Subject: [PATCH 2/2] Updated documentation to explain the new YearlyMicroposts parameter. --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d981823..40eeb07 100644 --- a/README.md +++ b/README.md @@ -88,9 +88,9 @@ You can then control the name and weight of these menus in your `config.toml` by If you aren't sure of how this should look, see how [jnjosh.com uses this in it's config.toml](https://github.com/jnjosh/jnjosh.com/blob/master/config.toml). -**Recommendation:** Add `SectionPagesMenu` to your `config.toml` file. -**Recommendation:** Don't set a `menu` in your post's Front Matter unless you want it to display on the navigation. -**Recommendation:** Customize the menus that get an RSS icon by adding the `RSSSections` parameter to your `config.toml` file. +**Recommendation:** Add `SectionPagesMenu` to your `config.toml` file. +**Recommendation:** Don't set a `menu` in your post's Front Matter unless you want it to display on the navigation. +**Recommendation:** Customize the menus that get an RSS icon by adding the `RSSSections` parameter to your `config.toml` file. **Recommendation:** Configure the menu items by adding `menu.main` sections to your `config.toml` file. #### Defining yourself as the Author @@ -141,11 +141,12 @@ These posts are rendered slightly different with an → to signify that it is re | `[author]` - `LastName` | Your last name | Not really. It is used in some places to identify you as the author. | | `[author]` - `AboutPage` | `/about` or `http://about.othersite.com` | Only if you want an about page. This is exposed to allow you to link to an external about page as well. If you have a local page it can just be something relative. | | `[author]` - `Location` | `Your City` | No. If set, this is added to the Copyright in the footer so you can give some love to your hometown. | -| `[author]` - `FlickrID` | `Your Flickr ID` | Kind of. The footer shows your photo stream from flickr. If you don't set it you'll see random photos that Flickr serves you. | -| `[params]` - `Description` | `Describe your site` | No. If set this is added to your pages metadata. | +| `[author]` - `FlickrID` | `Your Flickr ID` | No. The footer shows your photo stream from flickr. If you don't set it, nothing will be displayed. | +| `[params]` - `Description` | `Describe your site` | No. If set, this is added to your pages metadata. | | `[params]` - `ShowCopyright` | `true` or `false` | No. If true, Copyright text will be added to the footer. | | `[params]` - `RSSEnabled` | `true` or `false` | No. If true, RSS pages will be generated. | -| `[params]` - `RSSSections` | `[ "Posts", "Microposts", "Photos" ]` | If you want RSS links in the menu, Yes. These strings need to be the display name of the section where you want to have an RSS icon displayed. ![rss](https://github.com/jnjosh/internet-weblog/blob/master/images/rss.png) | +| `[params]` - `RSSSections` | `[ "Posts", "Microposts", "Photos" ]` | If you want RSS links in the menu, yes. These strings need to be the display name of the section where you want to have an RSS icon displayed. ![rss](https://github.com/jnjosh/internet-weblog/blob/master/images/rss.png) | +| `[params]` - `YearlyMicroposts` | `true` or `false` | No. If true, Microposts will have a page with a yearly grouping just like the posts. If not present or false, nothing happens. | Here is an example `config.toml`: