Explorar o código

feat: filter by author in Pages and Featured widgets

To use, just set an `author` filter to a username in instances of the Pages or Featured widget:

```
[content.filters]
    tag = ""
    category = ""
    publication_type = ""
    author = "admin"
```

Close #1422
George Cushen %!s(int64=5) %!d(string=hai) anos
pai
achega
90aca0659c

+ 1 - 0
exampleSite/content/home/featured.md

@@ -29,6 +29,7 @@ subtitle = ""
     tag = ""
     category = ""
     publication_type = ""
+    author = ""
   
 [design]
   # Toggle between the various page layout types.

+ 1 - 0
exampleSite/content/home/posts.md

@@ -28,6 +28,7 @@ subtitle = ""
     tag = ""
     category = ""
     publication_type = ""
+    author = ""
     exclude_featured = false
   
 [design]

+ 1 - 0
exampleSite/content/home/publications.md

@@ -28,6 +28,7 @@ subtitle = ""
     tag = ""
     category = ""
     publication_type = ""
+    author = ""
     exclude_featured = false
   
 [design]

+ 1 - 0
exampleSite/content/home/talks.md

@@ -28,6 +28,7 @@ subtitle = ""
     tag = ""
     category = ""
     publication_type = ""
+    author = ""
     exclude_featured = false
     exclude_past = false
     exclude_future = false

+ 4 - 0
layouts/partials/widgets/featured.html

@@ -24,6 +24,10 @@
   {{ $archive_page := site.GetPage (printf "publication_types/%s" $st.Params.content.filters.publication_type) }}
   {{ $query = $query | intersect $archive_page.Pages }}
 {{ end }}
+{{ if $st.Params.content.filters.author }}
+  {{ $archive_page = site.GetPage (printf "authors/%s" (urlize $st.Params.content.filters.author)) }}
+  {{ $query = $query | intersect $archive_page.Pages }}
+{{ end }}
 
 {{/* Sort */}}
 {{ $sort_by := "Date" }}

+ 4 - 0
layouts/partials/widgets/pages.html

@@ -30,6 +30,10 @@
   {{ $archive_page = site.GetPage (printf "publication_types/%s" $st.Params.content.filters.publication_type) }}
   {{ $query = $query | intersect $archive_page.Pages }}
 {{ end }}
+{{ if $st.Params.content.filters.author }}
+  {{ $archive_page = site.GetPage (printf "authors/%s" (urlize $st.Params.content.filters.author)) }}
+  {{ $query = $query | intersect $archive_page.Pages }}
+{{ end }}
 {{ if $st.Params.content.filters.exclude_featured }}
   {{ $query = where $query "Params.featured" "!=" true }}
 {{ end }}