Add paths to enable theming#2451
Open
raffaelj wants to merge 5 commits into
Open
Conversation
usage:
**.eleventy.js**
`eleventyConfig.path('views', './src/themes/base/layouts/');`
**./src/themes/base/layouts/default.njk**
`{% renderFile 'views:partials/head.njk' %}`
usage: `layout: "views:default.njk"`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #2101
fixes #930
I added a simple, but dynamic system for paths to simplify theming, to enable child theming and to use shorter path names in
renderFileshortcode. It is a concept from the Lime micro framework, which is the core of Cockpit CMS. I modified that concept to allow relative paths, which are used heavily in 11ty. Cockpit uses absolute paths instead. See also https://github.com/agentejo/cockpit/blob/next/lib/Lime/App.php#L348-L391Usage:
.eleventy.jsindex.njkSee more usages in the test files.
Let me know, if I did some mistakes with contributing guidelines etc. - and I'm prototyping here. So there is some cleanup with commented code to do. I'm fine, if this pull request doesn't make it into the core, but I would love to see a similar concept. If there is no chance, or if it would take a lot of time, I would fork the RenderPlugin, so I can use the child theme behavior with rendered partials and some hacks to simplify the layout system.