浏览代码

project widget: Enable content from any folder to be displayed

The widget is no longer limited to only displaying content from `content/project/` folder.

See #429
Dongdong Tian 7 年之前
父节点
当前提交
4167651b58
共有 2 个文件被更改,包括 8 次插入4 次删除
  1. 6 2
      exampleSite/content/home/projects.md
  2. 2 2
      layouts/partials/widgets/projects.html

+ 6 - 2
exampleSite/content/home/projects.md

@@ -1,6 +1,5 @@
 +++
 # Projects widget.
-# This widget displays all projects from `content/project/`.
 widget = "projects"
 active = true
 date = "2016-04-20T00:00:00"
@@ -11,6 +10,11 @@ subtitle = ""
 # Order that this section will appear in.
 weight = 50
 
+# Content.
+# Display content from the following folder.
+# For example, `folder = "project"` displays content from `content/project/`.
+folder = "project"
+
 # View.
 # Customize how projects are displayed.
 # Legend: 0 = list, 1 = cards.
@@ -27,7 +31,7 @@ filter_default = 0
 [[filter]]
   name = "All"
   tag = "*"
-  
+
 [[filter]]
   name = "Deep Learning"
   tag = ".deep-learning"

+ 2 - 2
layouts/partials/widgets/projects.html

@@ -34,7 +34,7 @@
     {{ if eq $page.Params.view 0 }}
 
     <div class="row isotope projects-container js-layout-row">
-        {{ range where $.Site.RegularPages "Type" "project" }}
+        {{ range where $.Site.RegularPages "Type" ($page.Params.folder | default "project") }}
         <div class="col-md-12 project-item isotope-item {{ delimit .Params.tags " " }}" itemscope itemtype="http://schema.org/CreativeWork">
           <i class="fa fa-files-o pub-icon" aria-hidden="true"></i>
 
@@ -56,7 +56,7 @@
 
     <div class="row isotope projects-container js-layout-masonry">
 
-      {{ range $project := where $.Site.RegularPages "Type" "project" }}
+      {{ range $project := where $.Site.RegularPages "Type" ($page.Params.folder | default "project") }}
       {{ $.Scratch.Set "project_url" $project.Permalink }}
       {{ $.Scratch.Set "target" "" }}
       {{ if $project.Params.external_link }}