mirror of
https://github.com/Findus23/acronomy.git
synced 2024-09-09 04:03:44 +02:00
extend sitemap.xml
This commit is contained in:
parent
39c5c17381
commit
559f331cbc
2 changed files with 30 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
from django.contrib.sitemaps import Sitemap
|
||||
from django.urls import reverse
|
||||
|
||||
from .models import Acronym
|
||||
from .models import Acronym, Tag
|
||||
|
||||
|
||||
class AcronymSitemap(Sitemap):
|
||||
|
@ -12,3 +13,27 @@ class AcronymSitemap(Sitemap):
|
|||
|
||||
def lastmod(self, obj: Acronym):
|
||||
return obj.modified_date
|
||||
|
||||
|
||||
class TagsSitemap(Sitemap):
|
||||
changefreq = "weekly"
|
||||
priority = 0.5
|
||||
|
||||
def items(self):
|
||||
return Tag.objects.all()
|
||||
|
||||
|
||||
class StaticPagesSitemap(Sitemap):
|
||||
changefreq = "weekly"
|
||||
priority = 0.9
|
||||
|
||||
def items(self):
|
||||
return [
|
||||
reverse("index"),
|
||||
reverse("overview"),
|
||||
reverse("tags"),
|
||||
reverse("integrations")
|
||||
]
|
||||
|
||||
def location(self, url):
|
||||
return url
|
||||
|
|
|
@ -7,14 +7,16 @@ from rest_framework import routers
|
|||
|
||||
from acronomy import settings
|
||||
from . import views
|
||||
from .sitemaps import AcronymSitemap
|
||||
from .sitemaps import AcronymSitemap, StaticPagesSitemap, TagsSitemap
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'acronym', views.AcronymViewSet)
|
||||
router.register(r'tag', views.TagViewSet)
|
||||
|
||||
sitemaps = {
|
||||
"acronyms": AcronymSitemap
|
||||
"static": StaticPagesSitemap,
|
||||
"acronyms": AcronymSitemap,
|
||||
"tags": TagsSitemap
|
||||
}
|
||||
|
||||
urlpatterns = [
|
||||
|
|
Loading…
Reference in a new issue