Skip to content

Commit c9d352d

Browse files
committed
Remove Jekyll cruft, update search and plugins to use Eleventy variables
1 parent fa1e448 commit c9d352d

File tree

13 files changed

+38
-99
lines changed

13 files changed

+38
-99
lines changed

.eleventy.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import yaml from 'js-yaml';
44
import fs from 'fs';
55
import path from 'path';
66

7+
const ICON_REGEX = /{%\s+include\s+["']?\/?icons\/([\w-]+)\.svg["']?\s+%}/g;
8+
79
export default function (eleventyConfig) {
810
// Get baseurl from environment or use default
911
const baseurl = process.env.BASEURL || '/design-system';
@@ -48,20 +50,23 @@ export default function (eleventyConfig) {
4850
return url.startsWith('/') ? baseurl + url : baseurl + '/' + url;
4951
});
5052

51-
eleventyConfig.addFilter('markdownify', function (content) {
53+
const renderIcons = (content) => {
5254
if (!content) return '';
5355
const iconsDir = path.resolve('docs/_includes/icons');
54-
const withIcons = content.replace(
55-
/{%\s+include\s+\/?icons\/([\w-]+)\.svg\s+%}/g,
56-
(match, icon) => {
57-
const iconPath = path.join(iconsDir, `${icon}.svg`);
58-
if (!fs.existsSync(iconPath)) return match;
59-
return fs
60-
.readFileSync(iconPath, { encoding: 'utf8', flag: 'r' })
61-
.trim();
62-
},
63-
);
64-
return md.render(withIcons);
56+
return content.replace(ICON_REGEX, (match, icon) => {
57+
const iconPath = path.join(iconsDir, `${icon}.svg`);
58+
if (!fs.existsSync(iconPath)) return match;
59+
return fs.readFileSync(iconPath, { encoding: 'utf8', flag: 'r' }).trim();
60+
});
61+
};
62+
63+
eleventyConfig.addFilter('render_icons', function (content) {
64+
return renderIcons(content);
65+
});
66+
67+
eleventyConfig.addFilter('markdownify', function (content) {
68+
if (!content) return '';
69+
return md.render(renderIcons(content));
6570
});
6671

6772
// Custom collection for pages by section
@@ -97,7 +102,7 @@ export default function (eleventyConfig) {
97102
},
98103
});
99104

100-
// Custom permalink computation matching Jekyll plugin behavior
105+
// Custom permalinks
101106
eleventyConfig.addGlobalData('eleventyComputed', {
102107
permalink: (data) => {
103108
// Skip if permalink is already set
@@ -132,8 +137,7 @@ export default function (eleventyConfig) {
132137
});
133138

134139
// Add date filters
135-
eleventyConfig.addFilter('date', function (date, format) {
136-
// Simple date formatting - you can use a library like luxon for more complex formatting
140+
eleventyConfig.addFilter('date', function (date) {
137141
if (!date) return '';
138142
const d = new Date(date);
139143
return d.toISOString();

.eleventyignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ TERMS.md
1010
CODE_OF_CONDUCT.md
1111
CONTRIBUTING.md
1212
HISTORY.md
13-
Gemfile
14-
Gemfile.lock
1513
esbuild
1614
packages
1715
scripts

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,3 @@ docs/fonts/
8585
docs/_site
8686
.lighthouseci
8787
.sass-cache
88-
**/.jekyll-cache/
89-
.jekyll-metadata
90-
Gemfile.lock

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ here's what you'd do:
3434
1. `cd design-system`
3535
1. `git checkout main && git pull` to ensure you're on the latest changes (this step is not necessary when cloning for the first time).
3636
1. `yarn install` to install dependencies and set up [workspaces](https://yarnpkg.com/lang/en/docs/workspaces/)
37-
1. `yarn after-install` to copy assets and configure Ruby dependencies.
37+
1. `yarn after-install` to copy assets.
3838
1. `git checkout -b button-fix` to create a new branch for your changes.
3939
1. Edit file(s) in `/packages/cfpb-design-system/src/components/cfpb-buttons` however you want.
4040
1. Copy `/packages/cfpb-design-system/` into `node_modules/@cfpb/cfpb-design-system/` in your consumerfinance.gov or other repo.
@@ -213,4 +213,5 @@ Example of a valid JSON token file structure for our project.
213213
}
214214
},
215215
```
216+
216217
Figma emits JSON color that adears to the [w3c design token spec](https://www.designtokens.org/tr/drafts/color/#format). Editors can supply only hex values, srgb int or srgb float while ignoring the Figma specifc metadata.

Gemfile

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/_includes/search-scripts.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
{% assign variations_count = 0 %}
66
// This is an inline script attached to the window so that we can utilize
7-
// jekyll's liquid variables, such as site.pages.
7+
// Eleventy's liquid variables, such as site.pages.
88
window.searchStore = {
9-
{% for page in site.pages %}
9+
{% for page in collections.all %}
1010

1111
{% comment %} Exclude search page itself from results. {% endcomment %}
12-
{% if url == 'search/index' %} {% continue %} {% endif %}
12+
{% if page.url == 'search/index' %} {% continue %} {% endif %}
1313

14-
'{{ url | slugify }}': {
14+
'{{ page.url | slugify }}': {
1515

1616
// Cycle through the variation fields of this page.
17-
{% for variation_group in variation_groups %}
17+
{% for variation_group in page.data.variation_groups %}
1818
// Determine the maximum number of variations present overall.
1919
{% if variation_group.variations.size > variations_count %}
2020
{% assign variations_count = variation_group.variations | size %}
@@ -28,14 +28,14 @@
2828
{% endfor %}
2929

3030

31-
'title': '{{ title | escape }}',
32-
'description': {{ page.description | markdownify | strip_html | url_encode | jsonify }},
33-
'use_cases': {{ page.use_cases | markdownify | strip_html | url_encode | jsonify }},
34-
'guidelines': {{ page.guidelines | markdownify | strip_html | url_encode | jsonify }},
35-
'behavior': {{ page.behavior | markdownify | strip_html | url_encode | jsonify }},
36-
'accessibility': {{ page.accessibility | markdownify | strip_html | url_encode | jsonify }},
37-
'research': {{ page.research | markdownify | strip_html | url_encode | jsonify }},
38-
'related_items': {{ page.related_items | markdownify | strip_html | url_encode | jsonify }},
31+
'title': "{{ page.data.title | escape }}",
32+
'description': {{ page.data.description | markdownify | strip_html | url_encode | jsonify }},
33+
'use_cases': {{ page.data.use_cases | markdownify | strip_html | url_encode | jsonify }},
34+
'guidelines': {{ page.data.guidelines | markdownify | strip_html | url_encode | jsonify }},
35+
'behavior': {{ page.data.behavior | markdownify | strip_html | url_encode | jsonify }},
36+
'accessibility': {{ page.data.accessibility | markdownify | strip_html | url_encode | jsonify }},
37+
'research': {{ page.data.research | markdownify | strip_html | url_encode | jsonify }},
38+
'related_items': {{ page.data.related_items | markdownify | strip_html | url_encode | jsonify }},
3939
'url': '{{ url | escape }}'
4040
}
4141
{% unless forloop.last %},{% endunless %}

docs/_includes/search.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<form id="search-form" action="{{ site.baseurl }}/search" method="get">
1+
<form id="search-form" action="{{ site.baseurl }}/search/" method="get">
22
<cfpb-form-search id="search-box" form="search-form" name="searchQuery">
33
<ul>
44
<li><a href="/design-system/components/alerts">Alerts</a></li>

docs/_includes/variation-content.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ <h3>
133133
<!-- Live code example -->
134134
{% if variation_code_snippet and variation_code_snippet != '' %}
135135
<div class="a-live__code">
136-
{{ variation_code_snippet }}
136+
{{ variation_code_snippet | render_icons }}
137137
</div>
138138
{% endif %}
139139

docs/_layouts/variation.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
{% include "sidebar.html" %}
77

88
<div class="ds-content">
9-
{% include "variation-content.html" %} {% if page.variation_groups.size > 0
10-
%}
9+
{% include "variation-content.html" %} {% if variation_groups.size > 0 %}
1110

1211
<div class="o-editor" id="toggle-details">
1312
<a class="a-btn" href="#" title="Show all details">

docs/_plugins/permalinks.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)