summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-07-11 23:37:24 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2022-07-11 23:37:24 +0300
commite0f98cddc7a9b2fc984f208551e82477161eac45 (patch)
treeed0485a5e6225c9e79ed3fe3f2f8029156161546
parenta1e6e600d0a2e1bda0776db2346bc8bf1e3ddb0f (diff)
Attempt #3
-rw-r--r--build.js4
-rw-r--r--src/admin/config.yml3
-rw-r--r--src/index.html.mustache6
3 files changed, 8 insertions, 5 deletions
diff --git a/build.js b/build.js
index 1a472fc..df9b486 100644
--- a/build.js
+++ b/build.js
@@ -43,6 +43,10 @@ const galleryViews = galleryJsonList
.map((fileName) => fs.readFileSync(path.join(GALLERY_DIR, fileName), "utf-8"))
.map(JSON.parse)
.map((gallery) => {
+ // If display_title is "-", do not render a title. Netlify CMS doesn't support optionals well.
+ const display_title = gallery["display_title"].trim() !== "-"
+ ? gallery["display_title"]
+ : undefined;
const rows = sliceIntoChunks(gallery["images"], gallery["column_count"]);
const columns = transpose(rows);
return {
diff --git a/src/admin/config.yml b/src/admin/config.yml
index 4228091..c3dad3a 100644
--- a/src/admin/config.yml
+++ b/src/admin/config.yml
@@ -15,8 +15,7 @@ collections:
label: Sorting key (alphabetically first is shown first on page)
widget: string
- name: display_title
- label: Title (if defined, shown on page)
- optional: true
+ label: Displayed title (if no title, type "-")
widget: string
- name: column_count
label: Column count
diff --git a/src/index.html.mustache b/src/index.html.mustache
index 698e044..5133c9c 100644
--- a/src/index.html.mustache
+++ b/src/index.html.mustache
@@ -19,9 +19,9 @@
</header>
{{#galleries}}
- {{#title}}
- <h3>{{title}}</h3>
- {{/title}}
+ {{#display_title}}
+ <h3>{{display_title}}</h3>
+ {{/display_title}}
<div class="gallery">
{{#columns}}
<div class="column">