From 3726913c79ed725c06df3c13e7f9e228511c3fab Mon Sep 17 00:00:00 2001 From: Adaline Simonian Date: Fri, 23 Feb 2024 21:25:01 -0800 Subject: [PATCH] fix: korrekt handtering av feiltilfelle og vedleggsstiar i plugins --- _plugins/initials.rb | 4 ++++ _plugins/post_assets.rb | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/_plugins/initials.rb b/_plugins/initials.rb index 19ce990..624f87e 100644 --- a/_plugins/initials.rb +++ b/_plugins/initials.rb @@ -2,6 +2,10 @@ module Jekyll module InitialsFilter def initials(input) + if input.nil? || input.empty? + return input + end + input.split(' ').map { |n| n[0] }.join.upcase end end diff --git a/_plugins/post_assets.rb b/_plugins/post_assets.rb index a1d73f5..9cbef51 100644 --- a/_plugins/post_assets.rb +++ b/_plugins/post_assets.rb @@ -23,12 +23,12 @@ def render(context) end raise 'Could not find post' unless post - # For a published post - if post['published'] - "/assets/attachments/#{post['date'].strftime('%Y/%m/%d')}/#{post['slug']}/" - else - # For a draft + # For a draft + if post['draft'] "/assets/attachments/drafts/#{post['slug']}/" + else + # For a published post + "/assets/attachments/#{post['date'].strftime('%Y/%m/%d')}/#{post['slug']}/" end end end @@ -49,10 +49,10 @@ def post_asset_path(filename, post = nil) raise 'Could not find post data' unless post # Determine the asset path based on whether the post is published or a draft - asset_path = if post['published'] - "assets/attachments/#{post['date'].strftime('%Y/%m/%d')}/#{post['slug']}" - else + asset_path = if post['draft'] "assets/attachments/drafts/#{post['slug']}" + else + "assets/attachments/#{post['date'].strftime('%Y/%m/%d')}/#{post['slug']}" end # Concatenate the asset path with the filename