Skip to content

Commit

Permalink
Add the ability to exclude posts from the index with #noIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
danott committed Jan 14, 2024
1 parent a97a332 commit 6c0949f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/includable/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(string:, data:)
@posts =
data
.posts
.select { |p| p.fetch("date") > Date.parse("2023-12-01") }
.reject { |p| p.fetch("tags", []).include?("noIndex") }
.map do |p|
Post.new(p.fetch("title"), p.fetch("url"), p.fetch("date"))
end
Expand Down
7 changes: 3 additions & 4 deletions lib/markdown_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ def parse_plaintext_data_line(line)
when 2
wip_data[parts.first] = parts.last
when 1
begin
date = Date.parse(parts.first)
wip_data["date"] = date
rescue Date::Error
if parts.first.match(/\d\d\d\d-\d\d-\d\d/)
wip_data["date"] = Date.parse(parts.first)
else
wip_data["tags"] ||= []
wip_data["tags"] << parts.first
end
Expand Down

0 comments on commit 6c0949f

Please sign in to comment.