Make EnvironmentValues available in prepare().#765
Make EnvironmentValues available in prepare().#765JPToroDev wants to merge 2 commits intotwostraws:mainfrom JPToroDev:host
EnvironmentValues available in prepare().#765Conversation
|
I'm keen to avoid leaking implementation details if possible; if we can get @Environment to work in Site it would be preferable to passing in values. For example, in the case of making content available in prepare(), could we push the content parsing phase up so that it happens before prepare() is called? |
|
Sure, we could move The reason I went with this approach is because We could make them optional, but that might start to muck up the API. That, coupled with using a property wrapper outside of a view, struck me as a potential point of confusion. |
|
I also took a bit of inspiration from |
|
Think of it a bit like how SwiftUI's @State property wrapper can be used in a View or in the main App struct; both will work. You can also use it in an external view model class, but there SwiftUI will issue a runtime warning that you've screwed up. |
|
That makes sense. I'll submit a new PR with that approach. Then I think we're good to push a small tag and set our sights on the multilingual stuff. |
This PR gives users access to a subset of available environment values—like a site's articles—in
Site'sprepare()method.