-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should make it possible for users to export their site in a format easy to deploy on a static hosting site, e.g. Netlify This disables some of the features that make Kobweb powerful (e.g. dynamic routes and server API routes), but for many use cases, e.g. portfolios or blog sites, this is fine. Bug #22
- Loading branch information
1 parent
a65fa16
commit 703ee41
Showing
10 changed files
with
227 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
common/kobweb-common/src/main/kotlin/com/varabyte/kobweb/server/api/SiteLayout.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.varabyte.kobweb.server.api | ||
|
||
import com.varabyte.kobweb.common.error.KobwebException | ||
import com.varabyte.kobweb.project.conf.KobwebConf | ||
|
||
private val PROPERTY_SITE_LAYOUT = "kobweb.site.layout" | ||
|
||
enum class SiteLayout { | ||
/** | ||
* Files live in multiple roots as specified in the [KobwebConf] file. | ||
* | ||
* Furthermore, the files searched for are different in developement and production versions. | ||
* | ||
* With this format, your pages, resources, scripts, and server jar are served from all potentially different | ||
* locations, with a fallback `index.html` that can be used for unknown URLs. | ||
* | ||
* This format is guaranteed to support all Kobweb features, although it will require you hosting your own server | ||
* which might be more expensive than a static layout. | ||
*/ | ||
KOBWEB, | ||
|
||
/** | ||
* Files live in single root folder, from which they are served directly without any complex routing logic. | ||
* | ||
* This is ideal for serving simple static blog sites. External hosting providers should be able to handle this | ||
* layout. | ||
* | ||
* Kobweb server features and dynamic routing are not supported with this format. However, a huge advantage for this | ||
* format is it can often be served fast and cheap. | ||
*/ | ||
STATIC; | ||
|
||
companion object { | ||
fun get(): SiteLayout { | ||
val envValue: String = System.getProperty(PROPERTY_SITE_LAYOUT) ?: KOBWEB.name | ||
return SiteLayout.values().firstOrNull { layout -> layout.name == envValue } | ||
?: throw KobwebException("Invalid export layout: $envValue, expected one of [${ServerEnvironment.values().joinToString()}]") | ||
} | ||
} | ||
|
||
fun toSystemPropertyParam(): String = "-D${PROPERTY_SITE_LAYOUT}=${this.name}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.