diff --git a/incorporealcms/markdown.py b/incorporealcms/markdown.py index 68479b4..7e7bbf7 100644 --- a/incorporealcms/markdown.py +++ b/incorporealcms/markdown.py @@ -90,7 +90,7 @@ def handle_markdown_file_path(path: str) -> str: return template.render(title=page_title, config=Config, description=get_meta_str(md, 'description'), - image=get_meta_str(md, 'image'), + image=Config.BASE_HOST + get_meta_str(md, 'image'), content=content, base_url=Config.BASE_HOST + instance_resource_path_to_request_path(path), navs=parent_navs, diff --git a/incorporealcms/templates/base.html b/incorporealcms/templates/base.html index 9c4067e..4ed5295 100644 --- a/incorporealcms/templates/base.html +++ b/incorporealcms/templates/base.html @@ -5,9 +5,9 @@ SPDX-License-Identifier: GPL-3.0-only {{ title }} + {% if title %}{% endif %} {% if description %}{% endif %} - {% if image %}{% endif %} diff --git a/tests/functional_markdown_tests.py b/tests/functional_markdown_tests.py index ccddbf9..864ec29 100644 --- a/tests/functional_markdown_tests.py +++ b/tests/functional_markdown_tests.py @@ -63,3 +63,16 @@ def test_figures_are_rendered(): '') in data assert '
just a logo
' in data os.chdir(HERE) + + +def test_og_image(): + """Test that the og:image meta tag is present as expected.""" + with tempfile.TemporaryDirectory() as tmpdir: + src_dir = os.path.join(HERE, 'instance') + ssg = StaticSiteGenerator(src_dir, tmpdir) + os.chdir(os.path.join(src_dir, 'pages')) + + ssg.build_file_in_destination(os.path.join(HERE, 'instance', 'pages'), '', 'more-metadata.md', tmpdir, True) + with open(os.path.join(tmpdir, 'more-metadata.html'), 'r') as graphviz_output: + data = graphviz_output.read() + assert ('