diff options
author | Bradley Taunt <bt@btxx.org> | 2024-07-23 13:23:58 -0400 |
---|---|---|
committer | Bradley Taunt <bt@btxx.org> | 2024-07-23 13:23:58 -0400 |
commit | b26d9cf7ec4c66b1dda34f61853904d31ff7fea0 (patch) | |
tree | f5faae91815b63fb78e8c8ba7c64d84d583d2b3c | |
parent | 6aee501b0e796b8721308451bb4f4f8a5d0e3fe7 (diff) |
Revert to match existing wruby project
-rw-r--r-- | wruby.rb | 19 |
1 files changed, 4 insertions, 15 deletions
@@ -45,16 +45,6 @@ def extract_title_from_md(lines) first_line&.start_with?('# ') ? first_line[2..-1].strip : 'Blog Index' end -# Grab the date from each markdown file -def extract_date_from_md(lines) - date_str = lines[2]&.strip - begin - date_str ? DateTime.parse(date_str).new_offset(0) : DateTime.now.new_offset(0) - rescue Date::Error - DateTime.now.new_offset(0) - end -end - # Convert markdown files def process_markdown_files(input_directory, output_directory, header_content, footer_content) items = [] @@ -66,7 +56,7 @@ def process_markdown_files(input_directory, output_directory, header_content, fo lines = md_content.lines title = extract_title_from_md(lines) - date = extract_date_from_md(lines) + date = Date.parse(lines[2]&.strip || '') rescue Date.today html_content = Kramdown::Document.new(md_content).to_html relative_path = path.sub(input_directory + '/', '').sub('.md', '') @@ -123,7 +113,7 @@ def generate_rss(posts, rss_file, author_name, site_name, site_url, posts_dir) maker.channel.link = site_url posts.each do |post| - date = DateTime.parse(post[:date].to_s).new_offset('+05:00') + date = DateTime.parse(post[:date].to_s).to_time.utc item_link = "#{site_url}/#{posts_dir}/#{post[:link]}" item_title = post[:title] item_content = post[:content] @@ -131,8 +121,8 @@ def generate_rss(posts, rss_file, author_name, site_name, site_url, posts_dir) maker.items.new_item do |item| item.link = item_link item.title = item_title - item.updated = date.to_time.to_s - item.pubDate = date.to_time.rfc822 + item.updated = date.to_s + item.pubDate = date.rfc822 item.description = item_content end end @@ -141,7 +131,6 @@ def generate_rss(posts, rss_file, author_name, site_name, site_url, posts_dir) File.write(rss_file, rss) end - # Process header, posts, pages, etc. header_content = File.read(header_file) |