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
Show file tree
Hide file tree
Changes from all 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 microsite/docs/docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/_sass/light-style/_features.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
margin: 0 0 10px 0;
}
.masthead-button {
text-align: center;
width: 106px;
margin-top: $base-point-grid * 2;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/_sass/light-style/_masthead.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
}

.masthead-button {
text-align: center;
color: $white-color;
padding: 11px ($base-point-grid * 5);
border: 2px solid $white-color;
Expand Down
7 changes: 6 additions & 1 deletion src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -362,7 +366,8 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
micrositeUrl = micrositeUrl.value,
micrositeBaseUrl = micrositeBaseUrl.value,
micrositeDocumentationUrl = micrositeDocumentationUrl.value,
micrositeDocumentationLabelDescription = micrositeDocumentationLabelDescription.value
micrositeDocumentationLabelDescription = micrositeDocumentationLabelDescription.value,
micrositeHomeButtonTarget = micrositeHomeButtonTarget.value
),
gitSettings = MicrositeGitSettings(
githubOwner = micrositeGitHostingService.value match {
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 @@ -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),
Expand Down
8 changes: 1 addition & 7 deletions src/main/scala/microsites/layouts/FeaturesLayout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
Expand Down
16 changes: 2 additions & 14 deletions src/main/scala/microsites/layouts/HomeLayout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
)
),
Expand All @@ -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 %}",
Expand Down
20 changes: 20 additions & 0 deletions src/main/scala/microsites/layouts/Layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion src/test/scala/microsites/util/Arbitraries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import microsites.MicrositeKeys._
import microsites._
import org.scalacheck.Arbitrary
import org.scalacheck.Gen._
import org.scalacheck.Gen

trait Arbitraries {

Expand Down Expand Up @@ -143,6 +144,7 @@ trait Arbitraries {
micrositeEditButton ← micrositeEditButtonArbitrary.arbitrary
micrositeVersionList ← Arbitrary.arbitrary[Seq[String]]
micrositeSearchBar <- Arbitrary.arbitrary[Boolean]
micrositeHomeButtonTarget <- Gen.oneOf("docs", "repo")
} yield MicrositeSettings(
MicrositeIdentitySettings(
name,
Expand Down Expand Up @@ -184,7 +186,8 @@ trait Arbitraries {
micrositeUrl,
micrositeBaseUrl,
micrositeDocumentationUrl,
micrositeDocumentationLabelDescription
micrositeDocumentationLabelDescription,
micrositeHomeButtonTarget
),
MicrositeGitSettings(
githubOwner,
Expand Down