Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add requires_theme to site.collection #290

Open
kjaymiller opened this issue Oct 22, 2023 · 1 comment
Open

add requires_theme to site.collection #290

kjaymiller opened this issue Oct 22, 2023 · 1 comment
Labels
Milestone

Comments

@kjaymiller
Copy link
Collaborator

kjaymiller commented Oct 22, 2023

Some custom collections will have associated themes with them. We need to provide these themes by default.

Perhaps a "required_themes" could be for included themes loaders.

This way the custom collection or page object can include a loader that would be added to the site when the @site.collection|page is added.

Example

# site.py
# in the Site class
    def collection(self, Collection: type[Collection]) -> Collection:
        _Collection = Collection()
        ###### NEW####
        for theme in getattr(_Collection, "required_themes", []):
            site.engine.loaders.insert(theme, 0)
         ##############
        plugins = [*self.plugins, *getattr(_Collection, "plugins", [])]
        ...
@kjaymiller
Copy link
Collaborator Author

Not sure why I acted like site doesn't have a way to do this already

Better Example:

Example

# site.py
# in the Site class
    def collection(self, Collection: type[Collection]) -> Collection:
        _Collection = Collection()
        ###### NEW####
            self.register_themes(getattr(_Collection, "required_themes", [])
         ##############
        plugins = [*self.plugins, *getattr(_Collection, "plugins", [])]
        ...

We could also just call them themes. It's a little odd that we would call them just themes where with plugins we're passing the site's plugins in at rendering time. (At least that's the desired outcome)

It seems plugins aren't behaving as desired.

@kjaymiller kjaymiller added good first issue Good for newcomers themes labels Nov 17, 2023
@kjaymiller kjaymiller added this to the Backlog milestone Dec 13, 2023
@kjaymiller kjaymiller removed the good first issue Good for newcomers label Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

1 participant