Skip to content

Commit

Permalink
Improved error reporting in social plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Jul 10, 2023
1 parent b3ade9f commit 10b1501
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions material/plugins/social/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ def on_page_markdown(self, markdown, page, config, files):
if "description" in page.meta:
description = page.meta["description"]

# Check type of meta title - see https://t.ly/m1Us
if not isinstance(title, str):
log.error(
f"Page meta title of page '{page.file.src_uri}' must be a "
f"string, but is of type \"{type(title)}\"."
)
sys.exit(1)

# Check type of meta description - see https://t.ly/m1Us
if not isinstance(description, str):
log.error(
f"Page meta description of '{page.file.src_uri}' must be a "
f"string, but is of type \"{type(description)}\"."
)
sys.exit(1)

# Generate social card if not in cache - TODO: values from mkdocs.yml
hash = md5("".join([
site_name,
Expand Down
16 changes: 16 additions & 0 deletions src/plugins/social/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ def on_page_markdown(self, markdown, page, config, files):
if "description" in page.meta:
description = page.meta["description"]

# Check type of meta title - see https://t.ly/m1Us
if not isinstance(title, str):
log.error(
f"Page meta title of page '{page.file.src_uri}' must be a "
f"string, but is of type \"{type(title)}\"."
)
sys.exit(1)

# Check type of meta description - see https://t.ly/m1Us
if not isinstance(description, str):
log.error(
f"Page meta description of '{page.file.src_uri}' must be a "
f"string, but is of type \"{type(description)}\"."
)
sys.exit(1)

# Generate social card if not in cache - TODO: values from mkdocs.yml
hash = md5("".join([
site_name,
Expand Down

0 comments on commit 10b1501

Please sign in to comment.