44# ########## Libraries #############
55# ##################################
66
7+
78# standard
9+ from collections .abc import MutableMapping
810from dataclasses import dataclass , field
911from datetime import datetime
1012from pathlib import Path
11- from typing import Optional
13+ from typing import Any , Optional
14+
15+ # 3rd party
16+ from mkdocs .structure .pages import Page
1217
1318# package modules
1419from mkdocs_rss_plugin .__about__ import __title__ , __version__
1823# ##################################
1924
2025
26+ @dataclass
27+ class MkdocsPageSubset :
28+ """Minimal subset of a Mkdocs Page with only necessary attributes for plugin needs."""
29+
30+ dest_uri : str
31+ src_uri : str
32+ title : Optional [str ] = None
33+ meta : Optional [MutableMapping [str , Any ]] = None
34+
35+ @classmethod
36+ def from_page (cls , page : Page ) -> "MkdocsPageSubset" :
37+ """Create a PageSubset from a Mkdocs page.
38+
39+ Args:
40+ page: MkDocs Page object
41+ """
42+ return cls (
43+ meta = page .meta ,
44+ title = page .title ,
45+ src_uri = page .file .src_uri ,
46+ dest_uri = page .file .dest_uri ,
47+ )
48+
49+
2150@dataclass
2251class PageInformation :
2352 """Object describing a page information gathered from Mkdocs and used as feed's item."""
@@ -33,6 +62,9 @@ class PageInformation:
3362 updated : Optional [datetime ] = None
3463 url_comments : Optional [str ] = None
3564 url_full : Optional [str ] = None
65+ _mkdocs_page_ref : Optional [MkdocsPageSubset ] = field (
66+ default = None , repr = False , compare = False
67+ )
3668
3769
3870@dataclass
0 commit comments