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

Allow config to specify if home-page button goes to repo or docs #540

Merged
merged 6 commits into from
Jan 28, 2021
Merged
Changes from 1 commit
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
Next Next commit
Add config for call-to-action button target
  • Loading branch information
sloshy committed Jan 27, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit cc7b7f91dfb455c472cbcab9cd4a6cf6200cff9b
2 changes: 2 additions & 0 deletions microsite/docs/docs/settings.md
Original file line number Diff line number Diff line change
@@ -290,6 +290,8 @@ Each file (the map key) can be related to a specific configuration through the `
micrositePluginsDirectory := (resourceDirectory in Compile).value / "site" / "plugins"
```

- `micrositeHomeButtonTarget`: Where the large "call-to-action button" on your home page should take users. By default is set to `repo` for your project repository. Can be set to `docs` to take users to the project documentation page, if configured.

- `micrositeSearchEnabled`: Whether or not the search bar functionality is enabled for your microsite. Enabled by default. To disable, set to `false`.

- `micrositeTheme`: You can choose two different themes to generate your microsite. By default it will display the `light` theme but you have the option of choosing the classic `pattern` theme.
7 changes: 6 additions & 1 deletion src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
@@ -214,6 +214,10 @@ trait MicrositeKeys {
val micrositeSearchEnabled: SettingKey[Boolean] = settingKey[Boolean](
"Adds a search bar and search features to your website using Lunr.js. Default is 'true'"
)

val micrositeHomeButtonTarget: SettingKey[String] = settingKey[String](
"Determines where the large, home-page call-to-action button links to. Default is 'repo' which links to the project open source repository. Can also be set to `docs` to link to your main documentation page."
)
}

object MicrositeKeys extends MicrositeKeys
@@ -362,7 +366,8 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
micrositeUrl = micrositeUrl.value,
micrositeBaseUrl = micrositeBaseUrl.value,
micrositeDocumentationUrl = micrositeDocumentationUrl.value,
micrositeDocumentationLabelDescription = micrositeDocumentationLabelDescription.value
micrositeDocumentationLabelDescription = micrositeDocumentationLabelDescription.value,
micrositeHomeButtonTarget = "repo"
),
gitSettings = MicrositeGitSettings(
githubOwner = micrositeGitHostingService.value match {
1 change: 1 addition & 0 deletions src/main/scala/microsites/MicrositesPlugin.scala
Original file line number Diff line number Diff line change
@@ -123,6 +123,7 @@ object MicrositesPlugin extends AutoPlugin {
micrositeEditButton := None,
micrositeGithubLinks := true,
micrositeSearchEnabled := true,
micrositeHomeButtonTarget := "repo",
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.jpeg" | "*.gif" | "*.js" | "*.swf" | "*.md" | "*.webm" | "*.ico" | "CNAME" | "*.yml" | "*.svg" | "*.json",
includeFilter in Jekyll := (includeFilter in makeSite).value || "LICENSE",
commands ++= Seq(publishMicrositeCommand),
8 changes: 1 addition & 7 deletions src/main/scala/microsites/layouts/FeaturesLayout.scala
Original file line number Diff line number Diff line change
@@ -50,13 +50,7 @@ class FeaturesLayout(config: MicrositeSettings) extends Layout(config) {
cls := "features-header-description",
h1(cls := "masthead-title", config.identity.name),
p(cls := "masthead-description", config.identity.description),
a(
href := config.gitSiteUrl,
target := "_blank",
rel := "noopener noreferrer",
cls := "masthead-button",
s"View on ${config.gitSettings.gitHostingService.name}"
)
ctaButton("masthead-button")
),
div(cls := "features-image")
)
16 changes: 2 additions & 14 deletions src/main/scala/microsites/layouts/HomeLayout.scala
Original file line number Diff line number Diff line change
@@ -71,13 +71,7 @@ class HomeLayout(config: MicrositeSettings) extends Layout(config) {
h2(),
p(
cls := "text-center",
a(
href := config.gitSiteUrl,
target := "_blank",
rel := "noopener noreferrer",
cls := "btn btn-outline-inverse",
s"View on ${config.gitSettings.gitHostingService.name}"
)
ctaButton("btn btn-outline-inverse")
)
)
),
@@ -91,13 +85,7 @@ class HomeLayout(config: MicrositeSettings) extends Layout(config) {
div(
cls := "container text-center",
h1(cls := "masthead-description", config.identity.description),
a(
href := config.gitSiteUrl,
target := "_blank",
rel := "noopener noreferrer",
cls := "masthead-button",
s"View on ${config.gitSettings.gitHostingService.name}"
)
ctaButton("masthead-button")
)
),
"{% if page.position != null %}",
20 changes: 20 additions & 0 deletions src/main/scala/microsites/layouts/Layout.scala
Original file line number Diff line number Diff line change
@@ -557,4 +557,24 @@ abstract class Layout(config: MicrositeSettings) {

private[this] def validFile(extension: String)(file: File): Boolean =
file.getName.endsWith(s".$extension")

def ctaButton(linkClass: String): TypedTag[String] = {
if (config.urlSettings.micrositeHomeButtonTarget == "repo") {
a(
href := config.gitSiteUrl,
target := "_blank",
rel := "noopener noreferrer",
cls := linkClass,
s"View on ${config.gitSettings.gitHostingService.name}"
)
} else {
a(
href := s"/${config.urlSettings.micrositeBaseUrl}${config.urlSettings.micrositeDocumentationUrl}",
target := "_blank",
rel := "noopener noreferrer",
cls := linkClass,
s"View Docs"
)
}
}
}
3 changes: 2 additions & 1 deletion src/main/scala/microsites/microsites.scala
Original file line number Diff line number Diff line change
@@ -58,7 +58,8 @@ case class MicrositeUrlSettings(
micrositeUrl: String,
micrositeBaseUrl: String,
micrositeDocumentationUrl: String,
micrositeDocumentationLabelDescription: String
micrositeDocumentationLabelDescription: String,
micrositeHomeButtonTarget: String
)

case class MicrositeFavicon(filename: String, sizeDescription: String)