summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--_gallery/01-testigalleria.json17
-rw-r--r--_gallery/02-otsikoton.json27
-rw-r--r--_gallery/03-löllöl.json12
-rw-r--r--_gallery/03-penis.json12
-rw-r--r--build.js28
5 files changed, 12 insertions, 84 deletions
diff --git a/_gallery/01-testigalleria.json b/_gallery/01-testigalleria.json
deleted file mode 100644
index 79c7c22..0000000
--- a/_gallery/01-testigalleria.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "column_count": 2,
- "images": [
- {
- "title": "Hassu",
- "src_thumbnail": "/media/hassu.png",
- "src_hiq": "/media/hassu.png"
- },
- {
- "title": "Halo",
- "src_thumbnail": "/media/halo.png",
- "src_hiq": "/media/halo.png"
- }
- ],
- "display_title": "Testigalleria",
- "title": "01-testigalleria"
-} \ No newline at end of file
diff --git a/_gallery/02-otsikoton.json b/_gallery/02-otsikoton.json
deleted file mode 100644
index eed2413..0000000
--- a/_gallery/02-otsikoton.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "column_count": 3,
- "images": [
- {
- "title": "Hassu",
- "src_thumbnail": "/media/hassu.png",
- "src_hiq": "/media/hassu.png"
- },
- {
- "title": "Halo",
- "src_thumbnail": "/media/halo.png",
- "src_hiq": "/media/halo.png"
- },
- {
- "title": "asd",
- "src_thumbnail": "/media/hassu.png",
- "src_hiq": "/media/hassu.png"
- },
- {
- "src_thumbnail": "/media/imagine-dragons-levykansi_mockup-custom-.jpg",
- "src_hiq": "/media/imagine-dragons-levykansi_mockup.jpg",
- "title": "Levykansi"
- }
- ],
- "display_title": "-",
- "title": "00-otsikoton"
-} \ No newline at end of file
diff --git a/_gallery/03-löllöl.json b/_gallery/03-löllöl.json
deleted file mode 100644
index cbd50c8..0000000
--- a/_gallery/03-löllöl.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "column_count": 2,
- "images": [
- {
- "title": "Löl",
- "src_thumbnail": "/media/marika_web_res-2.jpg",
- "src_hiq": "/media/marika_high_res-1.jpg"
- }
- ],
- "title": "03-löllöl",
- "display_title": "-"
-} \ No newline at end of file
diff --git a/_gallery/03-penis.json b/_gallery/03-penis.json
deleted file mode 100644
index c723dc4..0000000
--- a/_gallery/03-penis.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "column_count": 1,
- "images": [
- {
- "title": "levee jäbä",
- "src_thumbnail": "/media/hassu.png",
- "src_hiq": "/media/hassu.png"
- }
- ],
- "title": "03-penis",
- "display_title": "iso levee"
-} \ No newline at end of file
diff --git a/build.js b/build.js
index c3d371c..af21c39 100644
--- a/build.js
+++ b/build.js
@@ -17,39 +17,35 @@ function transpose(matrix) {
return matrix[0].map((col, i) => matrix.map(row => row[i]));
}
-const GALLERY_DIR = "_gallery";
const SITE_CONFIG_DIR = "_configuration";
const SRC_DIR = "src";
const DIST_DIR = "dist";
const HTML_TEMP_PATH = path.join(SRC_DIR, "index.html.mustache");
const HTML_OUT_PATH = path.join(DIST_DIR, "index.html");
const CONTACT_INFO_PATH = path.join(SITE_CONFIG_DIR, "contact_info.json");
+const GALLERIES_PATH = path.join(SITE_CONFIG_DIR, "galleries.json");
fs.rmSync(DIST_DIR, { recursive: true, force: true });
fs.cpSync(SRC_DIR, DIST_DIR, { recursive: true });
const htmlTemplate = fs.readFileSync(HTML_TEMP_PATH, "utf-8");
-let galleryJsonList = [];
-try {
- galleryJsonList = fs.readdirSync(GALLERY_DIR);
-} catch (err) {
- if (err.message?.includes("ENOENT")) {
- console.warn("Could not read galleries, using empty list.");
- } else {
- throw err;
- }
-}
-
-const galleryViews = galleryJsonList
- .map((fileName) => fs.readFileSync(path.join(GALLERY_DIR, fileName), "utf-8"))
- .map(JSON.parse)
+const galleriesJson = fs.readFileSync(GALLERIES_PATH, "utf-8");
+const galleriesView = JSON.parse(galleriesJson)
+const galleryViews = galleriesView["galleries"]
.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 images = gallery["images"];
+ const columnCount = gallery["column_count"];
+ while (images.length < columnCount) {
+ images.push(null);
+ }
+
+ const rows = sliceIntoChunks(images, columnCount);
const columns = transpose(rows);
return {
...gallery,