@@ -2,34 +2,22 @@ class SitemapController < ApplicationController
22 STATIC_PAGES = %w[ terms-and-conditions savings-methodology accessibility vision-statement ] . freeze
33 POST_SECTION_NAMES = %w[ get-help-hiring jobseeker-guides ] . freeze
44
5- # rubocop:disable Metrics/AbcSize
65 def show
7- map = XmlSitemap ::Map . new ( service_domain , secure : !Rails . env . development? ) do |m |
8- add_live_vacancies ( m )
6+ map = XmlSitemap ::Map . new ( service_domain , secure : !Rails . env . development? ) do |sitemap |
7+ add_live_vacancies ( sitemap )
98
10- add_static_landing_pages ( m )
9+ add_static_landing_pages ( sitemap )
1110
12- add_location_landing_pages ( m )
11+ add_location_landing_pages ( sitemap )
1312
14- STATIC_PAGES . each { |static_page | m . add page_path ( static_page ) , period : "weekly" }
13+ STATIC_PAGES . each { |static_page | sitemap . add page_path ( static_page ) , period : "weekly" }
1514
16- POST_SECTION_NAMES . each do |section |
17- m . add posts_path ( section ) , period : "weekly"
18-
19- MarkdownDocument . all_subcategories ( section ) . each do |sub_category |
20- m . add subcategory_path ( section , sub_category . post_name ) , period : "weekly"
21- posts = MarkdownDocument . all ( section , sub_category . post_name )
22- posts . each do |post |
23- m . add post_path ( section , sub_category . post_name , post . post_name ) , period : "weekly"
24- end
25- end
26- end
15+ add_all_posts ( sitemap )
2716 end
2817
2918 expires_in 3 . hours
3019 render xml : map . render
3120 end
32- # rubocop:enable Metrics/AbcSize
3321
3422 private
3523
@@ -50,4 +38,18 @@ def add_location_landing_pages(sitemap)
5038 sitemap . add location_landing_page_path ( location . parameterize ) , period : "hourly"
5139 end
5240 end
41+
42+ def add_all_posts ( sitenap )
43+ POST_SECTION_NAMES . each do |section |
44+ sitenap . add posts_path ( section ) , period : "weekly"
45+
46+ MarkdownDocument . all_subcategories ( section ) . each do |sub_category |
47+ sitenap . add subcategory_path ( section , sub_category . post_name ) , period : "weekly"
48+ posts = MarkdownDocument . all ( section , sub_category . post_name )
49+ posts . each do |post |
50+ sitenap . add post_path ( section , sub_category . post_name , post . post_name ) , period : "weekly"
51+ end
52+ end
53+ end
54+ end
5355end
0 commit comments