From 4661fbcce6bca7d969b3f13da5b1e2074fd97519 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Mon, 23 Jul 2018 12:24:17 +0100 Subject: [PATCH] projects widget: Add support for tags containing spaces Fix case where tag may contain spaces Allow `tag` to be set directly to the name of an existing tag, e.g. `tag = "Deep Learning"` rather than requiring the CSS class name like `tag = ".deep-learning"`. Close #602 --- exampleSite/content/home/projects.md | 7 ++++--- layouts/partials/widgets/projects.html | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/exampleSite/content/home/projects.md b/exampleSite/content/home/projects.md index 53020bd3..623c26f1 100644 --- a/exampleSite/content/home/projects.md +++ b/exampleSite/content/home/projects.md @@ -26,7 +26,8 @@ view = 1 filter_default = 0 # 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 show all items, set `tag` to "*". +# To filter by a specific tag, set `tag` to an existing tag name. # To remove toolbar, delete/comment all instances of `[[filter]]` below. [[filter]] name = "All" @@ -34,11 +35,11 @@ filter_default = 0 [[filter]] name = "Deep Learning" - tag = ".deep-learning" + tag = "Deep Learning" [[filter]] name = "Other" - tag = ".demo" + tag = "Demo" +++ diff --git a/layouts/partials/widgets/projects.html b/layouts/partials/widgets/projects.html index 2f750064..7d6fbd87 100644 --- a/layouts/partials/widgets/projects.html +++ b/layouts/partials/widgets/projects.html @@ -22,7 +22,12 @@
{{ range $idx, $item := $page.Params.filter }} - {{ .name }} + {{ if or (eq (substr .tag 0 1) "*") (eq (substr .tag 0 1) ".") }} + {{ $.Scratch.Set "tag" .tag }} + {{ else }} + {{ $.Scratch.Set "tag" (printf ".%s" (urlize .tag)) }} + {{ end }} + {{ .name }} {{ end }}
@@ -35,7 +40,7 @@
{{ range where $.Site.RegularPages "Type" ($page.Params.folder | default "project") }} -
+
@@ -63,7 +68,7 @@ {{ $.Scratch.Set "project_url" $project.Params.external_link }} {{ $.Scratch.Set "target" "target=\"_blank\"" }} {{ end }} -
+
{{ with $project.Params.image_preview }}