-
After bypassing some issues I am trying to generate a landing page. I would like to know if the landing page is created as an To make sure I am not doing something obviously wrong I have copied and made minimal changes to the code obtained from the manual. Here is the configuration I use: object StorchSitePlugin {
val linkConfig = LinkConfig(apiLinks =
Seq(
// ApiLinks(baseUri = "http://localhost:4242/api/")
ApiLinks(baseUri = "https://storch.dev/api/")
)
)
val buildToolSelection = Selections(
SelectionConfig(
"build-tool",
ChoiceConfig("sbt", "sbt"),
ChoiceConfig("scala-cli", "Scala CLI")
).withSeparateEbooks
)
val tlSiteHeliumConfig = Helium.defaults
.site
.topNavigationBar(
// Must be defined using name !!
//homeLink = IconLink.internal(Root / "README.md", HeliumIcon.home),
homeLink = ButtonLink.external("http://somewhere.com/", "Button Link"),
navLinks = Seq(
//IconLink.internal(Root / "doc-2.md", HeliumIcon.download),
TextLink.external("http://somewhere.com/", "Text Link"),
ButtonLink.external("http://somewhere.com/", "Button Link")
),
versionMenu = VersionMenu.create(
versionedLabelPrefix = "Version:",
unversionedLabel = "Choose Version"
),
highContrast = true
)
.site.landingPage(
logo = Some(Image(ExternalTarget("http://my-site/my-image.jpg"))),
title = Some("Project Name"),
subtitle = Some("Fancy Hyperbole Goes Here"),
latestReleases = Seq(
ReleaseInfo("Latest Stable Release", "2.3.5"),
ReleaseInfo("Latest Milestone Release", "2.4.0-M2")
),
license = Some("MIT"),
titleLinks = Seq(
VersionMenu.create(unversionedLabel = "Getting Started"),
LinkGroup.create(
IconLink.external("https://github.com/abcdefg/", HeliumIcon.github),
IconLink.external("https://gitter.im/abcdefg/", HeliumIcon.chat),
IconLink.external("https://twitter.com/abcdefg/", HeliumIcon.twitter)
)
),
documentationLinks = Seq(
TextLink.internal(Root / "doc-1.md", "Doc 1"),
TextLink.internal(Root / "doc-2.md", "Doc 2")
),
projectLinks = Seq(
TextLink.internal(Root / "doc-1.md", "Text Link"),
ButtonLink.external("http://somewhere.com/", "Button Label"),
LinkGroup.create(
IconLink.internal(Root / "doc-2.md", HeliumIcon.demo),
IconLink.internal(Root / "doc-3.md", HeliumIcon.info)
)
),
teasers = Seq(
Teaser("Teaser 1", "Description 1"),
Teaser("Teaser 2", "Description 2"),
Teaser("Teaser 3", "Description 3")
)
)
... Here is the code to setup parsing and generation:
def createTransformer(sources: String, targetHTML:String) = {
// https://typelevel.org/Laika/latest/02-running-laika/02-library-api.html#separate-parsing-and-rendering
val parser = MarkupParser
.of(Markdown)
.using(GitHubFlavor)
.withConfigValue(linkConfig)
.withConfigValue(buildToolSelection)
//.withRawContent
.parallel[IO]
.withTheme(tlSiteHeliumConfig.build)
.build
val htmlRenderer = Renderer.of(HTML).parallel[IO].build
val epubRenderer = Renderer.of(EPUB).parallel[IO].build
val pdfRenderer = Renderer.of(PDF).parallel[IO].build
val allResources = for {
parse <- parser
html <- htmlRenderer
} yield (parse, html)
import cats.syntax.all._
val transformOp: IO[Unit] = allResources.use {
case (parser, htmlRenderer) =>
parser.fromDirectory(sources).parse.flatMap {
tree =>
val htmlOp = htmlRenderer.from(tree.root).toDirectory(targetHTML).render
htmlOp.map(_ => ())
}
}
transformOp
}
} And here is how it is executed: val result: IO[Unit] = StorchSitePlugin.createTransformer(siteTargetSource.toIO.getAbsolutePath, siteTmp.toIO.getAbsolutePath)
import cats.effect.unsafe.implicits.global
val syncResult1: Unit = result.unsafeRunSync()
I have noticed that if we do not provide a
On a related note, I have noticed that if I set the top navigation bar's Is there something else I must call/execute to generate the landing page just like the Transformer? TIA |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes, two things, the renderer must know the theme, too and ideally share the config of the parser: Renderer
.of(HTML)
.withConfig(parser.config)
.parallel[IO]
.withTheme(tlSiteHeliumConfig.build)
.build |
Beta Was this translation helpful? Give feedback.
-
This answered my question. I have searched the manual but did not see any reference to this requirement (although in hind site it seems obvious). Maybe this should be added to the documentation? Maybe in the "Separate Parsing and Rendering" section? If so, should I create an issue for this? Thanks once again. |
Beta Was this translation helpful? Give feedback.
Yes, two things, the renderer must know the theme, too and ideally share the config of the parser: