diff --git a/sitemapr/core.py b/sitemapr/core.py index 63a42a5..8c40a80 100644 --- a/sitemapr/core.py +++ b/sitemapr/core.py @@ -108,7 +108,12 @@ def _iter_page(self, page: Page) -> Iterator[SiteMapUrl]: if query_string else f"{self._base_url}{path}" ) - yield SiteMapUrl(loc=loc) + yield SiteMapUrl( + loc=loc, + lastmod=page.lastmod, + changefreq=page.changefreq, + priority=page.priority, + ) def _get_param_combinations( self, params: list[Param] | None diff --git a/sitemapr/models.py b/sitemapr/models.py index 30882d8..9c6f011 100644 --- a/sitemapr/models.py +++ b/sitemapr/models.py @@ -16,6 +16,9 @@ class Page(BaseModel): path: str query_params: list[Param] = [] path_params: list[Param] = [] + lastmod: str | None = None + changefreq: ChangeFreq | None = None + priority: float | None = None class SiteMapUrl(BaseModel): diff --git a/tests/test_core.py b/tests/test_core.py index 99097ea..6f95e44 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -25,6 +25,7 @@ def test_iter_url_works(): Page( path="/blog/{id}", path_params=[Param(name="id", values=["1", "2", "3"])], + changefreq="daily", ), Page( path="/blog/{id}/comments", @@ -117,19 +118,19 @@ def test_iter_url_works(): SiteMapUrl( loc="https://example.com/blog/1", lastmod=None, - changefreq=None, + changefreq="daily", priority=None, ), SiteMapUrl( loc="https://example.com/blog/2", lastmod=None, - changefreq=None, + changefreq="daily", priority=None, ), SiteMapUrl( loc="https://example.com/blog/3", lastmod=None, - changefreq=None, + changefreq="daily", priority=None, ), SiteMapUrl(