Open RianBrand opened 1 month ago
Here is a design proposal.
# usage in server_setup.py
writer.serve.configure_page_meta(title='Hello world', opengraph_tags={
"title": "Hello world"
})
# usage in server_setup.py, call before serving index.html to fetch dynamic data
writer.serve.configure_page_meta(title=generate_title, opengraph_tags=lambda: generate_opengraph)
def configure_page_meta(title: Union[str, Callable[[], str]] = "Writer Framework", opengraph_tags: Union[Dict[str, str], Callable[[], Dict[str, str]] = None) -> None:
"""
Configure Open Graph metadata for a web page.
"""
...
Declaration of Opengraph metadata
<html prefix="og: http://ogp.me/ns#">
<head>
<meta property="og:title" content="Title of your page">
<meta property="og:description" content="Description of the page">
<meta property="og:type" content="website">
<meta property="og:url" content="https://www.yoursite.com/your-page">
<meta property="og:image" content="https://www.yoursite.com/image.jpg">
<meta property="og:locale" content="en_EN">
<meta property="og:site_name" content="Writer Framework">
</head>
The file index.html
will contains the tag <!-- {{ opengraph_tags}} -->
. The tag will be replaced when serving the index.html
.
When posting a link to social media, the Title is shown as "Writer Framework" and not the AppName. It would be great to be able add opengraph metadata to an app.