diff --git a/_data/isdevelopment.js b/_data/isdevelopment.js index 5132e90..6c0f5a2 100644 --- a/_data/isdevelopment.js +++ b/_data/isdevelopment.js @@ -20,6 +20,13 @@ */ module.exports = function () { - // YOLO. - return /serve|watch/.test(process.argv.join()); + try { + // Check if process exists and has argv array (safe for Cloudflare Workers etc) + if (typeof process === "undefined" || !process || !process.argv || !Array.isArray(process.argv)) { + return false; + } + return /serve|watch/.test(process.argv.join()); + } catch (e) { + return false; + } }; diff --git a/posts/blog/2026/q1-2026.md b/posts/blog/2026/q1-2026.md new file mode 100644 index 0000000..80082b2 --- /dev/null +++ b/posts/blog/2026/q1-2026.md @@ -0,0 +1,18 @@ +--- +title: "Q1 2026" +date: 2026-04-01 +categories: + - "blog" +--- + +Introduction to Q1 2026. + +## January + +Lovely weekend away at Brownsover Hall, recently renovated local house. Romantic break with Mrs J, quality time together and loads of different meals (afternoon tea, evening meal and big breakfast). Decor is beautiful and food was pretty good but some of the customer service needs attention with us having to remind many waiters and waitresses for drinks. + +Returned the boy to + +## February + +## March diff --git a/posts/posts.11tydata.js b/posts/posts.11tydata.js index 2b04f11..2c63a82 100644 --- a/posts/posts.11tydata.js +++ b/posts/posts.11tydata.js @@ -1,12 +1,39 @@ const todaysDate = new Date(); -const isDev = require("../_data/isdevelopment")(); -function showDraft(data) { - if (isDev) return true; +function isDev() { + try { + if (typeof process === "undefined" || !process || !process.argv || !Array.isArray(process.argv)) { + return false; + } + return /serve|watch/.test(process.argv.join()); + } catch (e) { + return false; + } +} + +const isDevEnv = isDev(); + +function isPublished(data) { + if (!data) return true; + if (isDevEnv) return true; const isDraft = "draft" in data && data.draft !== false; - const isPostInFuture = - "scheduled" in data ? data.scheduled > todaysDate : false; - return !isDraft && !isPostInFuture; + return !isDraft; +} + +function isCollectionVisible(data) { + if (!data) return false; + if (!isPublished(data)) return false; + + if (isDevEnv) return true; + + // Robustly handle dates + const scheduledDate = "scheduled" in data && data.scheduled ? new Date(data.scheduled) : null; + const postDate = data.date ? new Date(data.date) : todaysDate; + + const isScheduledInFuture = scheduledDate && !isNaN(scheduledDate.getTime()) ? scheduledDate > todaysDate : false; + const isPostInFuture = postDate && !isNaN(postDate.getTime()) ? postDate > todaysDate : false; + + return !isScheduledInFuture && !isPostInFuture; } module.exports = () => { @@ -15,9 +42,9 @@ module.exports = () => { templateClass: "tmpl-post", eleventyComputed: { eleventyExcludeFromCollections: (data) => - showDraft(data) ? data.eleventyExcludeFromCollections : true, + data && isCollectionVisible(data) ? (data.eleventyExcludeFromCollections || false) : true, permalink: (data) => { - if (!showDraft(data)) return false; + if (!data || !isPublished(data)) return false; if (data.permalink) return data.permalink;