-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added localized URLs for every page through the FoundationMetadataPag…
…eMixin (#6849) * Added localized URLs for every page through the FoundationMetadataPageMixin * Cache sitemap * Localized sitemaps
- Loading branch information
1 parent
600901e
commit 8f0655d
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Solution came from Aleksi44 on Github: | ||
# https://github.com/wagtail/wagtail/issues/6583#issuecomment-798960446 | ||
from django.contrib.sitemaps import views as sitemap_views | ||
from wagtail.contrib.sitemaps.sitemap_generator import Sitemap | ||
|
||
|
||
class CustomSitemap(Sitemap): | ||
|
||
def items(self): | ||
return ( | ||
self.get_wagtail_site() | ||
.root_page | ||
.localized # This is missing from sitemap_generator | ||
.get_descendants(inclusive=True) | ||
.live() | ||
.public() | ||
.order_by('path') | ||
.specific()) | ||
|
||
|
||
def sitemap(request, **kwargs): | ||
sitemaps = {'wagtail': CustomSitemap(request)} | ||
return sitemap_views.sitemap(request, sitemaps, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters