浏览代码

refactor(project): projects not listing child pages

Simplify code to get content name by using `.File.ContentBaseName` -
it gets content name irrespective of whether page is a bundle or not.

See #800

BREAKING CHANGE

`url_project` can now only be used to link pages to external websites.
To link a page to a project page, use `projects` option.
George Cushen 6 年之前
父节点
当前提交
8010d5a45c
共有 3 个文件被更改,包括 2 次插入13 次删除
  1. 0 1
      archetypes/project/index.md
  2. 1 1
      exampleSite/content/publication/clothing-search/index.md
  3. 1 11
      layouts/project/single.html

+ 0 - 1
archetypes/project/index.md

@@ -25,7 +25,6 @@ external_link = ""
 url_pdf = ""
 url_code = ""
 url_dataset = ""
-url_project = ""
 url_slides = ""
 url_video = ""
 url_poster = ""

+ 1 - 1
exampleSite/content/publication/clothing-search/index.md

@@ -45,7 +45,7 @@ url_pdf = "http://eprints.soton.ac.uk/352095/1/Cushen-IMV2013.pdf"
 url_preprint = "http://eprints.soton.ac.uk/352095/1/Cushen-IMV2013.pdf"
 url_code = "#"
 url_dataset = "#"
-url_project = "#"
+url_project = ""
 url_slides = "#"
 url_video = "#"
 url_poster = "#"

+ 1 - 11
layouts/project/single.html

@@ -15,15 +15,7 @@
     {{ partial "page_author.html" . }}
 
     {{ $page := . }}
-    {{ $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. */}}
-    {{ $dir_sep := substr .Dir -1 1 }}
-    {{ $project = delimit (last 1 (split (substr .Dir 0 -1) $dir_sep)) "" }}
-    {{ end }}
-    {{ $project_path := .RelPermalink }}
+    {{ $project := .File.ContentBaseName }}
 
     {{ if (.Site.Params.projects.list_children | default true) }}
 
@@ -43,7 +35,6 @@
       {{ end }}
 
       {{ $items := where (where .Site.RegularPages "Type" "publication") ".Params.projects" "intersect" (slice $project) }}
-      {{ $items := $items | union (where (where .Site.RegularPages "Type" "publication") ".Params.url_project" $project_path) }}
       {{ $pubs_len := len $items }}
       {{ if ge $pubs_len 1 }}
         <h2>{{ (i18n "publications") }}</h2>
@@ -63,7 +54,6 @@
       {{ end }}
 
       {{ $items := where (where .Site.RegularPages "Type" "talk") ".Params.projects" "intersect" (slice $project) }}
-      {{ $items := $items | union (where (where .Site.RegularPages "Type" "talk") ".Params.url_project" $project_path) }}
       {{ $talks_len := len $items }}
       {{ if ge $talks_len 1 }}
         <h2>{{ (i18n "talks") }}</h2>