twostraws / IgniteSamples

Sample code for the Ignite static site generator.
Other
66 stars 15 forks source link

Confused about Images nested within a Text element #2

Closed cgaaf closed 7 months ago

cgaaf commented 7 months ago

Within the GridExamples page, I'm confused as to why the Image element is nested within a Text element. Could this be explained or elaborated further within the documentation?

https://github.com/twostraws/IgniteSamples/blob/1004b1326a99ec7190d458462cb38c8f124b2383/Sources/Pages/Concepts/GridExamples.swift#L30

twostraws commented 7 months ago

Happy to! I've been working on this alone for quite some time, so I was mentally flip-flopping between two competing ideas:

I changed my mind on this a lot during development, and I suspect the result is somewhat inconsistent. In this precise case, images are technically inline elements rather than block elements, but I suspect the real answer here is "no one cares" 🙂 I might switch them over to being a PageElement, which would allow them to be placed anywhere.

cgaaf commented 7 months ago

Thanks for explaining the image nesting! While I understand the desire to support valid HTML, I think the early stages of this project would benefit most from prioritizing ease of use, especially for Swift developers who may be less familiar with HTML's nuances.

Focusing on making website creation intuitive for Swift programmers would reduce the mental context switching required. Have you considered a solution that would allow images to be embedded with a more natural Swift syntax, while still ultimately generating valid inline HTML elements?

I've never contributed to an open source project before so I'm hopeful to contribute a solution but I've not found success yet.

I had explored something that looks a bit like this but haven't had a successful implementation yet:

extension Image {
    enum ElementType {
        case inline
        case page
    }

    init(_ name: String? = nil, description: String? = nil, type: ElementType = .inline) { ... }
}
twostraws commented 7 months ago

Yes, I agree with you; I'll correct this now.