Kotlin / kotlinx.html

Kotlin DSL for HTML
Apache License 2.0
1.63k stars 133 forks source link

OpenGraph meta tags support #117

Open sanderploegsma opened 5 years ago

sanderploegsma commented 5 years ago

The current implementation of HTML <meta> tags only include the name and content attributes, which makes it impossible to add OpenGraph tags, which are specified as follows [1]:

<html prefix="og: http://ogp.me/ns#">
<head>
<title>The Rock (1996)</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
...
</head>
...
</html>

As a workaround, it's possible to wrap the raw HTML inside unsafe, but I'd prefer not to.

[1] http://ogp.me/

sanderploegsma commented 5 years ago

Someone in the #ktor channel on Slack pointed me in the following direction:

meta {
    attributes["prefix"] = "og http://ogp.me/ns#"
    attributes["property"] = "og:title"
    content = "title"
}

Although not perfect, it's a better solution than raw HTML inside unsafe