Prechádzať zdrojové kódy

projects: Fix new folder-based projects breaking talk/publication links

George Cushen 6 rokov pred
rodič
commit
5e223515a2

+ 3 - 2
archetypes/publication/index.md

@@ -30,8 +30,9 @@ selected = false
 
 # Projects (optional).
 #   Associate this publication with one or more of your projects.
-#   Simply enter your project's filename without extension.
-#   E.g. `projects = ["deep-learning"]` references `content/project/deep-learning.md`.
+#   Simply enter your project's folder or file name without extension.
+#   E.g. `projects = ["deep-learning"]` references 
+#   `content/project/deep-learning/index.md`.
 #   Otherwise, set `projects = []`.
 projects = []
 

+ 3 - 2
archetypes/talk/index.md

@@ -27,8 +27,9 @@ selected = false
 
 # Projects (optional).
 #   Associate this talk with one or more of your projects.
-#   Simply enter your project's filename without extension.
-#   E.g. `projects = ["deep-learning"]` references `content/project/deep-learning.md`.
+#   Simply enter your project's folder or file name without extension.
+#   E.g. `projects = ["deep-learning"]` references 
+#   `content/project/deep-learning/index.md`.
 #   Otherwise, set `projects = []`.
 projects = []
 

+ 8 - 1
exampleSite/config.toml

@@ -217,7 +217,14 @@ enableGitInfo = false
     #   1 = Detailed
     #   2 = APA
     #   3 = MLA
-    publication_format = 3
+    #   4 = Stream
+    publication_format = 4
+
+    # Talk list format.
+    #   0 = Simple
+    #   1 = Detailed
+    #   2 = Stream
+    talk_format = 2
 
   # Social/Academic Networking
   #

+ 4 - 3
exampleSite/content/publication/clothing-search/index.md

@@ -30,10 +30,11 @@ selected = true
 
 # Projects (optional).
 #   Associate this publication with one or more of your projects.
-#   Simply enter your project's filename without extension.
-#   E.g. `projects = ["deep-learning"]` references `content/project/deep-learning.md`.
+#   Simply enter your project's folder or file name without extension.
+#   E.g. `projects = ["deep-learning"]` references 
+#   `content/project/deep-learning/index.md`.
 #   Otherwise, set `projects = []`.
-projects = ["example-external-project"]
+projects = ["internal-project"]
 
 # Tags (optional).
 #   Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags.

+ 3 - 2
exampleSite/content/publication/person-re-id/index.md

@@ -30,8 +30,9 @@ selected = false
 
 # Projects (optional).
 #   Associate this publication with one or more of your projects.
-#   Simply enter your project's filename without extension.
-#   E.g. `projects = ["deep-learning"]` references `content/project/deep-learning.md`.
+#   Simply enter your project's folder or file name without extension.
+#   E.g. `projects = ["deep-learning"]` references 
+#   `content/project/deep-learning/index.md`.
 #   Otherwise, set `projects = []`.
 projects = []
 

+ 4 - 3
exampleSite/content/talk/example/index.md

@@ -27,10 +27,11 @@ selected = false
 
 # Projects (optional).
 #   Associate this talk with one or more of your projects.
-#   Simply enter your project's filename without extension.
-#   E.g. `projects = ["deep-learning"]` references `content/project/deep-learning.md`.
+#   Simply enter your project's folder or file name without extension.
+#   E.g. `projects = ["deep-learning"]` references 
+#   `content/project/deep-learning/index.md`.
 #   Otherwise, set `projects = []`.
-projects = ["deep-learning"]
+projects = ["internal-project"]
 
 # Tags (optional).
 #   Set `tags = []` for no tags, or use the form `tags = ["A Tag", "Another Tag"]` for one or more tags.

+ 17 - 3
layouts/project/single.html

@@ -17,8 +17,14 @@
     {{ partial "tags.html" . }}
 
     {{ $page := . }}
-    {{ $project := .File.TranslationBaseName }}
-    {{ $project_path := printf "%s/%s/" .Section $project }}
+    {{ $project := .Slug }}
+    {{ if not $project }}{{/* If user did not explicitly set `slug` in front matter. */}}
+    {{ $project = .File.TranslationBaseName }}
+    {{ end }}
+    {{ if eq $project "index" }}{{/* Check if using dir-based page bundles. */}}
+    {{ $project = delimit (last 1 (split (substr .Dir 0 -1) "/")) "" }}
+    {{ end }}
+    {{ $project_path := .RelPermalink }}
 
     {{ if (.Site.Params.projects.list_children | default true) }}
       {{ $items := where (where .Site.RegularPages "Type" "publication") ".Params.projects" "intersect" (slice $project) }}
@@ -33,6 +39,8 @@
             {{ partial "publication_li_apa" . }}
           {{ else if eq $page.Site.Params.projects.publication_format 3 }}
             {{ partial "publication_li_mla" . }}
+          {{ else if eq $page.Site.Params.projects.publication_format 4 }}
+            {{ partial "publication_li_stream" . }}
           {{ else }}
             {{ partial "publication_li_simple" . }}
           {{ end }}
@@ -45,7 +53,13 @@
       {{ if ge $talks_len 1 }}
         <h2>{{ (i18n "talks") }}</h2>
         {{ range sort $items ".Params.time_start" "desc" }}
-          {{ partial "talk_li_simple" . }}
+          {{ if eq $page.Site.Params.projects.talk_format 1 }}
+            {{ partial "talk_li_detailed" . }}
+          {{ else if eq $page.Site.Params.projects.talk_format 2 }}
+            {{ partial "talk_li_stream" . }}
+          {{ else }}
+            {{ partial "talk_li_simple" . }}
+          {{ end }}
         {{ end }}
       {{ end }}
     {{ end }}