From 9b5ed27977524e73e2dcb4ca176ecd0a9c1a19da Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 13 Oct 2022 10:41:44 +0200 Subject: [PATCH 1/2] Add fixture with draft: true --- tests/fixtures/docs/page_with_meta_draft_true.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/fixtures/docs/page_with_meta_draft_true.md diff --git a/tests/fixtures/docs/page_with_meta_draft_true.md b/tests/fixtures/docs/page_with_meta_draft_true.md new file mode 100644 index 00000000..34b1fd59 --- /dev/null +++ b/tests/fixtures/docs/page_with_meta_draft_true.md @@ -0,0 +1,8 @@ +--- +title: Page with partial meta but draft +draft: true +--- + +# Test page with partial meta but draft + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. From c1e4d5cd660ee2cb3efc487a5c946b1b0a2cf90d Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Thu, 13 Oct 2022 10:42:34 +0200 Subject: [PATCH 2/2] Exclude pages with draft=true in meta. Closes #147 --- mkdocs_rss_plugin/plugin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mkdocs_rss_plugin/plugin.py b/mkdocs_rss_plugin/plugin.py index 418811d5..4c9359b6 100644 --- a/mkdocs_rss_plugin/plugin.py +++ b/mkdocs_rss_plugin/plugin.py @@ -212,6 +212,11 @@ def on_page_content( if not self.match_path_pattern.match(page.file.src_path): return + # skip pages with draft=true + if page.meta.get("draft", False) is True: + logger.debug(f"Page {page.title} ignored because it's a draft") + return + # retrieve dates from git log page_dates = self.util.get_file_dates( in_page=page,