v0.20.4 #666
bitspittle
announced in
Announcements
v0.20.4
#666
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This release includes several miscellaneous fixes.
Perhaps one of the more interesting new features is that you can opt in to automatically convert external resource links declared in your
<head>
block into locally hosted files, which gets performed at build time.This can allow users to use a feature like Silk's font awesome icons or add a link into their build script to some external URL (e.g. for a font, script, or stylesheet) but then ask Kobweb automaticaly download and locally host it.
Important
Planning to upgrade? Review instructions in the README.
Changes
Frontend
navigateTo
when called on your current site's domain now behaves as a hybrid internal / external route.navigateTo("https://yoursite.com/about")
instead of justnavigateTo("/about")
Silk
OutlinedFilledCalloutVariant
for callouts.Backend
resources/public
folders and edited them during development.Request
andResponse
classes.request.readBody<SomeValue>()
andresponse.setBody<SomeValue>(someValue)
..kobweb/conf.yaml
but with incorrect indentation, so the server wasn't finding them and they didn't know.Gradle
<head>
elements, especially useful for converting CDNs into self-hosted resources.Notes
section for more details.kobwebSiteRoutes
extension property, allowing you to query all routes declared in your site.Notes
section for more details.kobwebStart -t
command outside of the site directory.Markdown
Notes
Intercepting URLs and self hosting
Many sites use a convenient solution for referencing external resources in their site through content delivery network, or CDN, links. Installation instructions for many web resources often recommend them as an option.
Unfortunately, this easy solution may result in a site not being GDPR compliant.
Note
Further discussion about GDPR is far outside the scope of these release notes, but if you're interested, you may want to review links like https://en.wikipedia.org/wiki/Content_delivery_network#Security_and_privacy and find blog posts discussing the topic.
A common way to deal with GDPR compliance is by self hosting resources yourself. However, there is no one-size-fits-all solution.
Kobweb wants to allow users to choose whatever solution works best for their needs, so in this release, we think we've found an easy way to support both -- by providing support for intercepting URLs found in
<head>
elements.You add URL interception rules through the
interceptUrls
block. Essentially, if you have a head element that references an external link, you can use URL interception to detect them and replace them with a new value, often a local path on your own server.Note
Such links might come from Kobweb libraries that you add as dependencies -- for example, the Kotlin Bootstrap library adds a few links of its own.
If you call
enableSelfHosting()
inside yourinterceptUrls
block, Kobweb will do all of this for you.For example, the
kobweb create examples/opengl
project has the following code in its build script:If you add
interceptUrls { enableSelfHosting() }
to theindex
block, then when you run and open the project, you'll see that a copy ofgl-matrix-min.js
was downloaded locally. If you inspect the site in the network tab of your dev tools and look at where thegl-matrix-min.js
is hosted, you'll see something like:http://yoursite.com/_kobweb/self-host/cdnjs.cloudflare.com/ajax/libs/gl-matrix/3.4.2/gl-matrix-min.js
If you want more manual control, the
interceptUrls
block also provides areplace
method:at which point, you'd be on the hook to add
/src/jsMain/resources/public/gl-matrix/script.js
to your project yourself.In general, CDN links offer quite a few advantages, so you shouldn't replace them just because it is easy to do so -- you'll increase your bandwidth bill, while you'll also likely serve those files much slower than a CDN would have. But at least now Kobweb can support projects that decide to make this change.
kobwebSiteRoutes
Querying the list of registered site routes in your Kobweb build script can be useful, for example letting you programmatically create a sitemap.
Using
kobwebSiteRoutes
in a custom task looks like this:Important
Note in the above example that the
kobwebSiteRoutes
property is queried during the task configuration phase and then its returned value is queried during the task execution phase. If you don't do this, Gradle may complain at you for invalidating cache requirements.Full Changelog: v0.20.3...v0.20.4
This discussion was created from the release v0.20.4.
Beta Was this translation helpful? Give feedback.
All reactions