Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the site absolute url for twitter:image #285

Merged
merged 6 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ trait MicrositeKeys {
val micrositeShareOnSocial: SettingKey[Boolean] = settingKey[Boolean](
"Optional. Includes links to share on social media in the layout. Enabled by default."
)
val micrositeUrl: SettingKey[String] = settingKey[String]("Microsite site absolute url prefix")
val micrositeBaseUrl: SettingKey[String] = settingKey[String]("Microsite site base url")
val micrositeDocumentationUrl: SettingKey[String] =
settingKey[String]("Microsite site documentation url")
Expand Down Expand Up @@ -223,6 +224,7 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
micrositePluginsDirectory = micrositePluginsDirectory.value
),
urlSettings = MicrositeUrlSettings(
micrositeUrl = micrositeUrl.value,
micrositeBaseUrl = micrositeBaseUrl.value,
micrositeDocumentationUrl = micrositeDocumentationUrl.value,
micrositeDocumentationLabelDescription = micrositeDocumentationLabelDescription.value
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/microsites/MicrositesPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ object MicrositesPlugin extends AutoPlugin {
else
organizationHomepage.value.map(_.toString).getOrElse("")
},
micrositeUrl := "",
micrositeBaseUrl := "",
micrositeDocumentationUrl := "",
micrositeDocumentationLabelDescription := "Documentation",
Expand Down
12 changes: 11 additions & 1 deletion src/main/scala/microsites/layouts/Layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ abstract class Layout(config: MicrositeSettings) {
meta(name := "author", content := config.identity.author),
meta(name := "description", content := config.identity.description),
meta(name := "og:image", content := "{{site.url}}{{site.baseurl}}/img/poster.png"),
// Linked-In requires this og:image tag format
meta(
name := "image",
attr("property") := "og:image",
content := "{{site.url}}{{site.baseurl}}/img/poster.png"),
meta(name := "og:title", content := pageTitle),
// For Linked-In
meta(name := "title", attr("property") := "og:title", content := pageTitle),
meta(name := "og:site_name", content := config.identity.name),
meta(name := "og:url", content := config.identity.homepage),
meta(name := "og:type", content := "website"),
Expand All @@ -125,7 +132,10 @@ abstract class Layout(config: MicrositeSettings) {
`type` := "image/png",
href := "{{site.url}}{{site.baseurl}}/img/favicon.png"),
meta(name := "twitter:title", content := pageTitle),
meta(name := "twitter:image", content := "{{site.url}}{{site.baseurl}}/img/poster.png"),
meta(
name := "twitter:image",
// Twitter image URL must be the absolute path
content := s"${config.urlSettings.micrositeUrl}{{site.baseurl}}/img/poster.png"),
meta(name := "twitter:description", content := config.identity.description),
meta(name := "twitter:card", content := "summary_large_image")
) ++ twitter.toList ++ twitterCreator.toList ++ kazariDep.toList ++ kazariRes.toList
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/microsites/microsites.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ case class MicrositeGitSettings(
gitSidecarChatUrl: String)

case class MicrositeUrlSettings(
micrositeUrl: String,
micrositeBaseUrl: String,
micrositeDocumentationUrl: String,
micrositeDocumentationLabelDescription: String)
Expand Down
2 changes: 2 additions & 0 deletions src/test/scala/microsites/util/Arbitraries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ trait Arbitraries {
micrositeExtraMdFiles ← markdownMapArbitrary.arbitrary
micrositeExtraMdFilesOutput ← Arbitrary.arbitrary[File]
micrositePluginsDirectory ← Arbitrary.arbitrary[File]
micrositeUrl ← Arbitrary.arbitrary[String]
micrositeBaseUrl ← Arbitrary.arbitrary[String]
micrositeDocumentationUrl ← Arbitrary.arbitrary[String]
micrositeDocumentationLabelDescription ← Arbitrary.arbitrary[String]
Expand Down Expand Up @@ -190,6 +191,7 @@ trait Arbitraries {
micrositePluginsDirectory
),
MicrositeUrlSettings(
micrositeUrl,
micrositeBaseUrl,
micrositeDocumentationUrl,
micrositeDocumentationLabelDescription),
Expand Down