Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add paths to enable theming#2451

Open
raffaelj wants to merge 5 commits into
11ty:mainfrom
raffaelj:add-paths-to-enable-theming
Open

Add paths to enable theming#2451
raffaelj wants to merge 5 commits into
11ty:mainfrom
raffaelj:add-paths-to-enable-theming

Conversation

@raffaelj
Copy link
Copy Markdown

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.

raffaelj added 5 commits June 21, 2022 11:04
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

Development

Successfully merging this pull request may close these issues.

Plugin Render: renderFile & path Theming system

1 participant