InterceptUrlsBlock

abstract class InterceptUrlsBlock @Inject constructor : ExtensionAware(source)

Configuration for intercepting URLs found inside a block.

Kobweb dependencies may add URLs to your block, but you may want to override or remove them for various reasons (usually because you want to handle setting up the dependencies yourself using locally downloaded files). This block lets you configure rules for exactly how to handle those URLs.

Not EVERY url inside a head block should be considered for interception. For example, <link rel="canonical" href="..."> is probably not something a user would want to change, if they added it. So to be safe, Kobweb will only consider URLs that correspond to:

  • Specific link rel types

    • stylesheet

    • icon

    • preload

    • prefetch

    • You can add additional types to this list using the linkRels property.

  • <script src="...">

  • @import url("...")

NOTE: Self-hosting is the most likely reason you'll want to intercept URLs, so see selfHosting for more information about how to do that.

Constructors

Link copied to clipboard
@Inject
constructor()

Properties

Link copied to clipboard
@get:Input
abstract val linkRels: SetProperty<String>

A list of <link rel='...'> values that Kobweb will consider for interception.

Functions

Link copied to clipboard
fun enableSelfHosting(excludes: Set<String> = emptySet())

Enable a processing step at build that time converts external resources into self-hosted files.

Link copied to clipboard
@Internal
abstract fun getExtensions(): ExtensionContainer
Link copied to clipboard
fun reject(url: String)

Register a URL which, if referenced in a block element, will result in it being removed.

Link copied to clipboard
fun replace(from: String, to: String)

Register a URL which, if referenced in a block element, should be replaced with the given value.