Wowchemy-hugo-modules: Projects Widget: Enable changing default filter from "all"

Created on 4 Jan 2017  路  7Comments  路  Source: wowchemy/wowchemy-hugo-modules

Using tags one can group the projects widget in the header of projects.md.
The default grouping is "All". Is there a quick way to change the default grouping which appears first on the webpage? I assume this is defined in the html theme file?

---
date: 2016-04-20T00:00:00
draft: false
filter:
- name: All
  tag: '*'
- name: R-packages
  tag: .R-package
- name: Science
  tag: .science
- name: Finished
  tag: .finished
subtitle: ""
title: Projects
view: 1
weight: 2
widget: projects
---
enhancement

All 7 comments

I guess the first filter option should always be the default one displayed when the page is loaded. What do you think?

The demo uses All as the first option, so there is no need for this extra logic in the demo, but I suppose it can be useful for sites that don't use All as the default.

Yeah that would be sufficient + a small note in the "Getting started" post that the default tag is the first one and that's it.

if I am not mistaken, this would also solve #100, that is, allow people to reuse the project widget, by just setting the default filter to something else.
Basically, it would just have to be possible to disable the all filter completely, and as a default.

Trying to use this feature on the example website, I simply changed the order of the filters in the TOML headers of projects.md to:

[[filter]]
  name = "Deep Learning"
  tag = ".deep-learning"

[[filter]]
  name = "Other"
  tag = ".demo"

[[filter]]
  name = "All"
  tag = "*"

The order of the toolbar does change, with All at the end, but All is still selected by default, with all projects displayed, and not Deep learning projects only. Am I missing something?

(hugo 0.27.1 with latest Academic from master)

Please update Academic. Then you can use the new filter_default option in the projects widget. For example, replace the old example filter code in the projects widget with the following:

# Filter toolbar.

# Default filter index (e.g. 0 corresponds to the first `[[filter]]` instance below).
filter_default = 1 # The second filter will now become the default!

# Add or remove as many filters (`[[filter]]` instances) as you like.
# Use "*" tag to show all projects or an existing tag prefixed with "." to filter by specific tag.
# To remove toolbar, delete/comment all instances of `[[filter]]` below.
[[filter]]
  name = "All"
  tag = "*"

[[filter]]
  name = "Deep Learning"
  tag = ".deep-learning"

[[filter]]
  name = "Other"
  tag = ".demo"

Excellent, thanks! Sorry if I missed the filter_default option before. It works beautifully with the filter order, which allows full flexibility on it!

@basille thanks for the feedback :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gcushen picture gcushen  路  3Comments

ivlis picture ivlis  路  4Comments

brianguay picture brianguay  路  4Comments

jacebenson picture jacebenson  路  3Comments

saadjavaid picture saadjavaid  路  3Comments