content icon indicating copy to clipboard operation
content copied to clipboard

Grouped content

Open stijns96 opened this issue 10 months ago • 8 comments

Is your feature request related to a problem? Please describe

I'm creating a docs for a big scala of sections and snippets where I want to group variants together. E.g. a content section can have 70 variations, but other sections as well. I want them all to be accessible as ./components/sections/section-name-1 etc. Not like ./components/sections/section-group/section-name-1/ Mainly because of the content navigation.

Describe the solution you'd like

Actually the same behaviour of the Nuxt grouped pages solution.

The think is that I want to group sections into categories, but don't want them to be grouped in the fetched navigation.

stijns96 avatar Feb 11 '25 15:02 stijns96

Hi @tomhillgreyridge - there is no built-in way to do this at the moment, I usually recommend doing what you did with the before. It's come up a few times, so I'm adding a feature request label.

tipsy avatar Oct 27 '24 07:10 tipsy

The obvious problem with refactoring this would be that HandlerType is an enum and so can't be extended by user classes. I guess one option would be to to use a sealed class or sealed interface so it could be extended by end users - only thing I am not sure of is how well sealed classes / interfaces interact with Java.

For now, this is a very specific and small proof of concept so I've just gone with a raw HTTP servlet - much as I miss the convenience of Javalin's methods on top of the request / response!

tomhillgreyridge avatar Oct 27 '24 15:10 tomhillgreyridge

For me the obvious hierarchy would be to have an internal handler type which covers your Javalin based handlers (before, after etc), then extend that to be a HttpHandlerType which adds GET, POST, PUT etc and then finally the user can extend to add a WebDavHandlerType (for example).

Something along the lines of this ugly proof of concept

sealed interface HandlerType {
    val name: String
    
    fun isInternal() = this is HandlerType.Internal;
    
    sealed class Internal(override val name: String) : HandlerType {
        data object BEFORE : Internal("BEFORE")
        data object BEFORE_MATCHED : Internal("BEFORE_MATCHED")
        data object AFTER : Internal("AFTER")
        data object AFTER_MATCHED : Internal("AFTER_MATCHED")
    }
}


sealed interface HttpHandlerType : HandlerType {
    companion object {
        fun fromString(method: String): HttpHandlerType {
            return Standard.values().find { it.name == method.uppercase() } ?: throw IllegalArgumentException("Unknown HTTP method: $method")
        }
    }
    
    fun isHttpMethod() = this is HttpHandlerType.Standard;
    
    enum class Standard : HttpHandlerType {
        GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, TRACE;
    }
}

sealed interface WebDavHandlerType : HttpHandlerType {
    enum class Methods : WebDavHandlerType {
        PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK;
    }
}


fun main(){
    val x = HttpHandlerType.fromString("GET")    
    println(x.name)
    println(x.isInternal())
    println(x.isHttpMethod())
}

tomhillgreyridge avatar Oct 27 '24 16:10 tomhillgreyridge