Skip to content

Commit

Permalink
Merge pull request #3 from 18F/default-assets
Browse files Browse the repository at this point in the history
Use USWDS CSS and JS by default
  • Loading branch information
shawnbot authored Mar 8, 2017
2 parents d98f8da + 8a952d1 commit c073ebd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
7 changes: 0 additions & 7 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
title: This is the site title

styles:
- /assets/uswds/css/uswds.min.css

scripts:
- src: /assets/uswds/js/uswds.min.js
async: true
17 changes: 15 additions & 2 deletions _includes/scripts.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
{% assign _scripts = '' | split: '' | push: site.scripts | push: layout.scripts | push: page.scripts | uniq %}
{% assign _scripts = '' | split: '' %}
{% assign _async_marker = 'uswds_async=true' %}
{% assign _site_scripts = site.scripts %}
{% unless _site_scripts -%}
{% assign _uswds_js = '/assets/uswds/js/uswds.min.js' | append: '?' | append: _async_marker %}
{% assign _site_scripts = '' | split: ''
| push: _uswds_js %}
{% endunless %}
{% assign _scripts = _scripts
| push: _site_scripts
| push: layout.scripts
| push: page.scripts
| uniq %}
{% for _list in _scripts %}{% for _script in _list %}
<script src="{{ _script.src | default: _script | relative_url }}" {% if _script.async %}async{% endif %}></script>
{% assign _src = _script.src | default: _script %}
<script src="{{ _src | replace: _async_marker, '' | relative_url }}"{% if _script.async or _src contains _async_marker %} async{% endif %}></script>
{% endfor %}{% endfor %}
13 changes: 12 additions & 1 deletion _includes/styles.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{% assign _styles = '' | split: '' | push: site.styles | push: layout.styles | push: page.styles | uniq %}
{% assign _styles = '' | split: '' %}
{% assign _site_styles = site.styles %}
{% unless _site.styles -%}
{% assign _uswds_css = '/assets/uswds/css/uswds.min.css' %}
{% assign _site_styles = '' | split: ''
| push: _uswds_css %}
{% endunless %}
{% assign _styles = _styles
| push: _site_styles
| push: layout.styles
| push: page.styles
| uniq %}
{% for _list in _styles %}{% for _style in _list %}
<link rel="stylesheet"
href="{{ _style.href | default: _style | relative_url }}"
Expand Down
2 changes: 1 addition & 1 deletion jekyll-uswds.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |spec|
spec.name = "jekyll-uswds"
spec.version = "0.1.1"
spec.version = "0.2.0"
spec.authors = ["Shawn Allen"]
spec.email = ["[email protected]"]

Expand Down

0 comments on commit c073ebd

Please sign in to comment.