Merge pull request #16876 from netchampfaris/fix-metatags-description

fix: description metatag
This commit is contained in:
gavin 2022-05-11 14:07:07 +05:30 committed by GitHub
commit ef971017c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 1 deletions

View file

@ -312,6 +312,11 @@ class TestWebsite(unittest.TestCase):
self.assertIn("test.__test", content)
self.assertNotIn("frappe.exceptions.ValidationError: Illegal template", content)
def test_metatags(self):
content = get_response_content("/_test/_test_metatags")
self.assertIn('<meta name="title" content="Test Title Metatag">', content)
self.assertIn('<meta name="description" content="Test Description for Metatag">', content)
def set_home_page_hook(key, value):
from frappe import hooks

View file

@ -16,7 +16,7 @@ class MetaTags:
def init_metatags_from_context(self):
for key in METATAGS:
if key not in self.tags and self.context.get(key):
if not self.tags.get(key) and self.context.get(key):
self.tags[key] = self.context[key]
if not self.tags.get("title"):

View file

@ -0,0 +1,5 @@
---
base_template: frappe/templates/web.html
---
<h1>Test Metatags</h1>

View file

@ -0,0 +1,8 @@
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
def get_context():
return {"title": "Test Title Metatag", "description": "Test Description for Metatag"}