Skip to content

Commit

Permalink
Merge pull request #77 from jtweeder/sitemaps
Browse files Browse the repository at this point in the history
sitemap changes for blog posts
  • Loading branch information
jtweeder committed Jul 13, 2023
2 parents 6604218 + e9c5f9a commit faf7edd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion mealcurator/sitemaps.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
from django.contrib import sitemaps
from django.urls import reverse
from stewpot.models import meal_posting


class StaticViewSitemap(sitemaps.Sitemap):
priority = 0.5
changefreq = 'daily'

def items(self):
return ['index', 'get-recipe', 'about', 'howto', 'change_log', 'ccc']
return ['index', 'get-recipe', 'about', 'howto', 'change_log', 'ccc', 'home-postings']

def location(self, item):
return reverse(item)

class BlogSitemap(sitemaps.Sitemap):
changefreq = "weekly"
priority = 0.5

def items(self):
return meal_posting.objects.all()

def lastmod(self, obj):
return obj.created_on

def location(self, obj):
return f'/share/post/{obj.id}'
4 changes: 2 additions & 2 deletions mealcurator/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from django.conf.urls import include
from django.urls import path
from django.contrib.sitemaps.views import sitemap
from .sitemaps import StaticViewSitemap
from .sitemaps import StaticViewSitemap, BlogSitemap

sitemaps = {'static': StaticViewSitemap}
sitemaps = {'static': StaticViewSitemap, 'blog': BlogSitemap}

urlpatterns = [
path('', include('meals.urls')),
Expand Down

0 comments on commit faf7edd

Please sign in to comment.