@@ -120,7 +120,7 @@ func (r *SitemapRepository) BuildNewsSitemap(
120120 }
121121
122122 urlSet .URLs = append (urlSet .URLs , sitemap.NewsURL {
123- Loc : fmt .Sprintf ("%s/news /%s" , baseURL , * p .Slug ),
123+ Loc : fmt .Sprintf ("%s/%s /%s" , baseURL , p . PostKind , * p .Slug ),
124124 News : sitemap.NewsMeta {
125125 Publication : sitemap.Publication {
126126 Name : siteName ,
@@ -208,7 +208,7 @@ func (r *SitemapRepository) BuildPostSitemap(
208208 }
209209
210210 urlSet .URLs = append (urlSet .URLs , sitemap.URL {
211- Loc : fmt .Sprintf ("%s/news /%s" , baseURL , * p .Slug ),
211+ Loc : fmt .Sprintf ("%s/%s /%s" , baseURL , p . PostKind , * p .Slug ),
212212 LastMod : p .UpdatedAt .UTC ().Format (time .RFC3339 ),
213213 Priority : priority ,
214214 ChangeFreq : map [bool ]string {true : "hourly" , false : "daily" }[age <= 24 * time .Hour ],
@@ -223,20 +223,36 @@ func (r *SitemapRepository) BuildPostSitemap(
223223 return append ([]byte (xml .Header ), output ... ), nil
224224}
225225
226- func (r * SitemapRepository ) GeneratePillarSitemap (ctx context.Context , baseURL string ) ([]byte , error ) {
226+ func (r * SitemapRepository ) GenerateCategoriesSitemap (ctx context.Context , baseURL string ) ([]byte , error ) {
227227
228228 var pillars []taxonomy.Pillar
229229 r .db .Find (& pillars )
230230
231+ err := r .db .
232+ Preload ("Clusters" ).
233+ Find (& pillars ).Error
234+
235+ if err != nil {
236+ return nil , err
237+ }
238+
231239 builder := sitemap .NewSitemapBuilder (baseURL )
232240
233241 var items []sitemap.SitemapItem
234242
235243 for _ , p := range pillars {
244+
236245 items = append (items , sitemap.SitemapItem {
237- Loc : builder .BuildLoc ("pillar /" + p .Slug ),
246+ Loc : builder .BuildLoc ("/" + p .Slug ),
238247 LastMod : p .UpdatedAt .UTC ().Format (time .RFC3339 ),
239248 })
249+
250+ for _ , c := range p .Clusters {
251+ items = append (items , sitemap.SitemapItem {
252+ Loc : builder .BuildLoc ("/" + p .Slug + "/" + c .Slug ),
253+ LastMod : c .UpdatedAt .UTC ().Format (time .RFC3339 ),
254+ })
255+ }
240256 }
241257
242258 return builder .BuildURLSitemap (items )
0 commit comments