Skip to content

Commit

Permalink
prefix netlify pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Gerhardt committed Mar 19, 2020
1 parent b7499ab commit 2d7211e
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions _categories/animals.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: animals
title: "COVID-19 and animals"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
1 change: 1 addition & 0 deletions _categories/biosafety.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: biosafety
title: "Laboratory biosafety"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
1 change: 1 addition & 0 deletions _categories/cdc-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: cdc-actions
title: "What CDC is doing"
promoted: false
owner: CDC
more_topics_promoted: true
more_topics_order: 6
banner:
Expand Down
1 change: 1 addition & 0 deletions _categories/community-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: community-events
title: "Community events"
promoted: false
owner: CDC
more_topics_promoted: true
more_topics_order: 7
banner:
Expand Down
1 change: 1 addition & 0 deletions _categories/diagnostic-panels.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: diagnostic-panels
title: "Laboratory diagnostic panels"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
1 change: 1 addition & 0 deletions _categories/funerals.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: funerals
title: "COVID-19 and funerals"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
1 change: 1 addition & 0 deletions _categories/healthcare-professionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: healthcare-professionals
title: "Healthcare professionals"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
1 change: 1 addition & 0 deletions _categories/k12-childcare.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: k12-childcare
title: "K-12 schools and childcare program administrators"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
1 change: 1 addition & 0 deletions _categories/ppe.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: ppe
title: "Personal Protective Equipment"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
1 change: 1 addition & 0 deletions _categories/pregnancy.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: pregnancy
title: "Pregnant women and COVID-19"
promoted: false
owner: CDC
more_topics_promoted: true
more_topics_order: 8
banner:
Expand Down
1 change: 1 addition & 0 deletions _categories/protect-others.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: protect-others
title: "How to protect others"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
1 change: 1 addition & 0 deletions _categories/waste-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: waste-management
title: "Waste management"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
1 change: 1 addition & 0 deletions _categories/water-transmission.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ layout: category
name: water-transmission
title: "Water transmission"
promoted: false
owner: CDC
banner:
display: false
heading: "This is a place to place urgent information"
Expand Down
16 changes: 15 additions & 1 deletion _plugins/jekyll_config_netlify_cms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
This iterates over all documents found in the `content` collection and
generates a `collection` for each unique subdirectory in _content.
=end

Jekyll::Hooks.register :site, :post_write do |site|
template = load_yaml(SOURCE_TEMPLATE)

categories = site.collections['categories'].docs
collections = site.collections['content'].docs
.map { |doc| doc.relative_path.split(SEP)[0..-2].join(SEP) }
.uniq
.map do |path|
stripped_path_parts = path.split(SEP)[1..]
template.merge({
'label' => stripped_path_parts.join(' | ').gsub(/-/, ' ').capitalize(),
'label' => make_label(stripped_path_parts, categories),
'name' => stripped_path_parts.join('--'),
'folder' => path,
})
Expand All @@ -44,4 +46,16 @@ def load_yaml(path)

def dump_yaml(path, hash)
File.open(path, 'w') { |file| file.write(hash.to_yaml) }
end

def find_owner(folder_path, categories)
puts folder_path
return "" if folder_path.nil?
category = categories.find { |category| category.data['name'] == folder_path }
"Owner:#{category.data['owner']} Posts:"
end

def make_label(paths, categories)
owner = find_owner(paths.first, categories)
owner + paths.join(' | ').gsub(/-/, ' ').capitalize()
end

0 comments on commit 2d7211e

Please sign in to comment.