Skip to content

Commit

Permalink
fix: korrekt handtering av feiltilfelle og vedleggsstiar i plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
adalinesimonian committed Feb 24, 2024
1 parent 6d3f975 commit 3726913
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions _plugins/initials.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions _plugins/post_assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3726913

Please sign in to comment.