Website for SwayDB written in Scala.js with scalajs-react.
All documentation pages are written in HTML/VDOM and prior knowledge of React is not required to update or add new documentation pages.
Create a Page type in Page.scala.
object MyPage extends Page {
import japgolly.scalajs.react.vdom.html_<^.{<, _}
override val name: String = "My page"
override val subPages: Seq[Page] = Seq()
override val url: String = "mypage/" //unique URL
override def render(): VdomElement =
<.div("My page") //implement the HTML for the page here or preferably in another object type.
}
- To add
MyPage
as one of the root pages, add it to theRootPages.pages
in Page.scala. - To add
MyPage
as one of thesubPages
of anotherPage
, add it to thesubPages
field of the targetPage
in Page.scala.
Done!
All Page
s follow the above structure that are simple HTML functions. Updating
the Pages require updating the HTML of the render
functions.
LinkIn(Page.MyPage)
LinkOut("http://swaydb.io/", "SwayDB docs")
ScalaCode(
"""
|object MyCodeSnippet {
|
| println("My code snippet")
|
|}
""".stripMargin
)
sbt fastOptJS
or
sbt fullOptJS //To build and minify.
Add ~
to start auto build on code changes.
sbt ~fastOptJS
All output JS files and other static files (html, css, img etc) are added to the docs
folder.
Run the following in the docs
folder to start serving index.html
on python server.
python -m SimpleHTTPServer
Read more on Scala.js documentation on building.