From 20085fa9bc28165e69115465d022c13494f1ad22 Mon Sep 17 00:00:00 2001 From: Oliver Byford Date: Mon, 8 Jan 2018 13:51:51 +0000 Subject: [PATCH] Allow for additional stylesheets per example For some examples (at the minute specifically the layout examples) we need to add additional styling to add borders or backgrounds to highlight individual elements within the example. At the minute this is being done by adding additional classes to the example (not yet committed), but this means that the app stylesheet is full of styles affecting only single examples, and the HTML and Nunjucks code includes extra classes which we would not want users to be copying into their own app. By allowing users to include additional stylesheets, the additional styling can exist in the same directory as the example and included from there. As an example, you might add the following to an example's frontmatter: --- layout: layout-example.njk stylesheets: - annotate-layout.css --- --- views/layouts/layout-example.njk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/views/layouts/layout-example.njk b/views/layouts/layout-example.njk index b6300a2394..45ae6528d8 100644 --- a/views/layouts/layout-example.njk +++ b/views/layouts/layout-example.njk @@ -7,6 +7,12 @@ {{ title }} + + {#- Include any additional stylesheets specified in the example frontmatter #} + {% for stylesheet in stylesheets %} + + {%- endfor %} +