Skip to content

Commit 18c2c34

Browse files
committed
fix(integration): Material Social Card URI was wrong for Material blog posts
Bug introduced in #354
1 parent d446712 commit 18c2c34

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

mkdocs_rss_plugin/integrations/theme_material_social_plugin.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,21 @@ def get_social_card_url_for_page(
378378
if mkdocs_site_url is None and self.mkdocs_site_url:
379379
mkdocs_site_url = self.mkdocs_site_url
380380

381-
# As of mkdocs-material 9.6.5, social cards are always stored in the
382-
# matching src path in the build folder, regardless of the page type.
383-
page_social_card = (
384-
f"{mkdocs_site_url}{self.social_cards_dir}/"
385-
f"{Path(mkdocs_page.src_uri).with_suffix('.png')}"
386-
)
381+
# if page is a blog post
382+
if (
383+
self.integration_material_blog.IS_BLOG_PLUGIN_ENABLED
384+
and self.integration_material_blog.is_page_a_blog_post(mkdocs_page)
385+
):
386+
page_social_card = (
387+
f"{mkdocs_site_url}assets/images/social/"
388+
f"{Path(mkdocs_page.dest_uri).with_suffix('.png')}"
389+
)
390+
else:
391+
page_social_card = (
392+
f"{mkdocs_site_url}{self.social_cards_dir}/"
393+
f"{Path(mkdocs_page.src_uri).with_suffix('.png')}"
394+
)
395+
387396
logger.debug(f"Use social card url: {page_social_card}")
388397

389398
return page_social_card

0 commit comments

Comments
 (0)