-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show meta tag for Open Graph Protocol
- Loading branch information
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
modules/core/shared/src/main/scala/scaladex/core/model/OGP.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package scaladex.core.model | ||
|
||
/** | ||
* Open Graph Protocol, see https://ogp.me/ | ||
* | ||
* @param title | ||
* @param url | ||
* @param description | ||
* @param image | ||
* @param imageAlt | ||
*/ | ||
case class OGP( | ||
title: String, | ||
url: Url, | ||
description: String, | ||
image: Option[Url] = None, | ||
imageAlt: Option[String] = None | ||
) { | ||
val `type`: String = "article" | ||
val siteName: String = "Scaladex" | ||
def toHeadMeta: Seq[HeadMeta] = Seq( | ||
HeadMeta(name = "og:title", content = title), | ||
HeadMeta(name = "og:url", content = url), | ||
HeadMeta(name = "og:description", content = description), | ||
HeadMeta(name = "og:site_name", content = siteName) | ||
) ++ image.map(c => HeadMeta(name = "og:image", content = c.target)) ++ imageAlt.map(c => | ||
HeadMeta(name = "og:image:alt", c) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters