Skip to content

Commit

Permalink
Helium: add CSS for custom content on landing page (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshalm committed Feb 7, 2024
1 parent 38e4408 commit 3964bb1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
29 changes: 27 additions & 2 deletions io/src/main/resources/laika/helium/css/landing.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ p {
margin: 0;
padding: 0;
}
ul {
#header ul {
list-style: none;
display: block;
margin: 0;
Expand All @@ -82,7 +82,7 @@ ul {
background-color: var(--subtle-highlight);
margin-bottom: 5px;
}
li {
#header li {
padding: 0 10px 0 10px;
display: block;
font-size: 16px;
Expand Down Expand Up @@ -307,3 +307,28 @@ li {
right: 0;
margin: auto;
}

/* content from landing-page.md =================================================== */

main {
width: 100%;
margin-right: auto;
margin-left: auto;
margin-bottom: 70px;
padding: 15px;
}

@media (min-width: 1020px) {
main {
max-width: var(--content-width);
padding: 15px 30px;
}
}

h1.title {
padding-top: 30px;
}

main p {
margin: 0 0 var(--block-spacing);
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ <h2>${_.title}</h2>
@:@
</div>
@:@
${cursor.currentDocument.content}
@:if(helium.site.landingPage.hasCustomContent)
<main>
${cursor.currentDocument.content}
</main>
@:@

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package laika.helium.internal.generate
import cats.data.Kleisli
import cats.syntax.all.*
import cats.effect.Sync
import laika.api.config.ConfigBuilder
import laika.api.config.{ Config, ConfigBuilder }
import laika.ast.Path.Root
import laika.ast.{ Document, Element, RootElement }
import laika.config.LaikaKeys
Expand All @@ -35,26 +35,26 @@ private[helium] object LandingPageGenerator {
(d.content, d.fragments, d.config)
}.getOrElse((RootElement.empty, Map.empty[String, Element], tree.root.config))

def createConfig(base: Config): Config = base
.withValue(LaikaKeys.versioned, false).build
.withValue("helium.site.landingPage.hasCustomContent", landingPageContent.content.nonEmpty)
.build

val titleDocument = tree.root.titleDocument.fold(
TitleDocumentConfig.inputName(tree.root.config).map { inputName =>
Document(
path = Root / inputName,
content = landingPageContent
)
.withFragments(fragments)
.withConfig(landingPageConfig.withValue(LaikaKeys.versioned, false).build)
.withConfig(createConfig(landingPageConfig))
}
) { titleDoc =>
val config =
landingPageConfig.withFallback(titleDoc.config).withValue(
LaikaKeys.versioned,
false
).build
Right(
titleDoc
.appendContent(landingPageContent.content)
.addFragments(fragments)
.withConfig(config)
.withConfig(createConfig(landingPageConfig.withFallback(titleDoc.config)))
)
}

Expand Down
2 changes: 2 additions & 0 deletions io/src/test/scala/laika/helium/HeliumLandingPageSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ class HeliumLandingPageSpec extends CatsEffectSuite with InputBuilder with Resul
|</div>
|<p class="header">Some <em>Header</em></p>
|$teaserHTML
|<main>
|<p>Some <em>markup</em> here.</p>
|</main>
|</body>""".stripMargin
val imagePath = Root / "home.png"
val helium = Helium.defaults
Expand Down

0 comments on commit 3964bb1

Please sign in to comment.