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 paths to enable theming #2451

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

raffaelj
Copy link

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 renderFile shortcode. 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-L391

Usage:

+ _layouts
  + themes
    + base
      - default.njk
      - footer.njk
- .eleventy.js
- index.njk

.eleventy.js

eleventyConfig.path('views', './_layouts/themes/base');

index.njk

---
layout: "views:default.njk"
---
some content
{% renderFile "views:footer.njk" %}

See 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.

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"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugin Render: renderFile & path Theming system
1 participant