Skip to content

Commit 97bf492

Browse files
authored
Merge pull request #31 from JavaScriptMN/11ty
11ty
2 parents a40f851 + b9c20a3 commit 97bf492

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+8728
-19525
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
charset = utf-8
10+
insert_final_newline = true
11+
indent_style = space
12+
indent_size = 2

.eleventy.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
const fs = require('fs');
2+
const inclusiveLangPlugin = require('@11ty/eleventy-plugin-inclusive-language');
3+
const cacheBuster = require('@mightyplow/eleventy-plugin-cache-buster');
4+
const htmlmin = require('html-minifier');
5+
const { minify } = require('terser');
6+
const siteSettings = require('./src/globals/site.json');
7+
const {
8+
version: eleventyVersion,
9+
} = require('./node_modules/@11ty/eleventy/package.json');
10+
11+
module.exports = function (eleventyConfig) {
12+
eleventyConfig.addPassthroughCopy('./src/css/tailwind.include.css');
13+
eleventyConfig.addPassthroughCopy({ public: './' });
14+
15+
eleventyConfig.addShortcode('year', function () {
16+
return new Date().getFullYear().toString();
17+
});
18+
19+
eleventyConfig.addShortcode('eleventyVersion', function () {
20+
return `Eleventy ${eleventyVersion}`;
21+
});
22+
23+
eleventyConfig.addFilter('formatDateTime', function (date) {
24+
return date.toLocaleDateString('en-US', {
25+
year: 'numeric',
26+
month: 'long',
27+
day: 'numeric',
28+
weekday: 'long',
29+
hour: 'numeric',
30+
minute: 'numeric',
31+
timeZoneName: 'short',
32+
});
33+
});
34+
35+
eleventyConfig.addPlugin(inclusiveLangPlugin);
36+
37+
if (process.env.ELEVENTY_ENV === 'production') {
38+
eleventyConfig.addPlugin(cacheBuster({ outputDirectory: 'dist' }));
39+
40+
eleventyConfig.addTransform('htmlmin', function (content, outputPath) {
41+
if (outputPath && outputPath.endsWith('.html')) {
42+
return htmlmin.minify(content, {
43+
useShortDoctype: true,
44+
removeComments: true,
45+
collapseWhitespace: true,
46+
});
47+
}
48+
49+
return content;
50+
});
51+
}
52+
53+
eleventyConfig.addNunjucksAsyncFilter('jsmin', async function (
54+
code,
55+
callback
56+
) {
57+
if (process.env.ELEVENTY_ENV === 'production') {
58+
try {
59+
const minified = await minify(code);
60+
callback(null, minified.code);
61+
} catch (err) {
62+
console.error('Terser error: ', err);
63+
// Fail gracefully.
64+
callback(null, code);
65+
}
66+
} else {
67+
callback(null, code);
68+
}
69+
});
70+
71+
eleventyConfig.setBrowserSyncConfig({
72+
callbacks: {
73+
ready: function (err, bs) {
74+
bs.addMiddleware('*', (req, res) => {
75+
const content_404 = fs.readFileSync('dist/404.html');
76+
// Provides the 404 content without redirect.
77+
res.write(content_404);
78+
// Add 404 http status code in request header.
79+
res.writeHead(404, { 'Content-Type': 'text/html' });
80+
res.end();
81+
});
82+
},
83+
},
84+
});
85+
86+
return {
87+
pathPrefix: siteSettings.baseUrl,
88+
dir: {
89+
input: 'src',
90+
output: 'dist',
91+
includes: 'includes',
92+
layouts: 'includes/layouts',
93+
data: 'globals',
94+
},
95+
};
96+
};

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches: [build]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Setup node
11+
uses: actions/setup-node@v1
12+
with:
13+
node-version: '14.x'
14+
- name: Install dependencies
15+
run: npm ci
16+
- name: Build site
17+
run: npm run build

.github/workflows/deploy.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Deploy
2+
on:
3+
push:
4+
branches:
5+
- build
6+
jobs:
7+
deploy:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Setup node
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: '14.x'
15+
- name: Install dependencies
16+
run: npm ci
17+
- name: Build site
18+
run: npm run build
19+
- name: Deploy
20+
uses: peaceiris/actions-gh-pages@v3
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
publish_branch: master
24+
publish_dir: ./dist

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Project dependencies
22
.cache
33
node_modules
4-
yarn-error.log
54

65
# Build directory
7-
/public
6+
/dist
87
.DS_Store
98

109
# IDE specific
1110
.idea/
1211
.vscode/
12+
13+
*.include.css

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/dist
2+
*.include.css
3+
package.json
4+
package-lock.json

.prettierrc

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

.travis.yml

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

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
# JavaScriptMN
2-
This site is generated with [Gatsby.js](https://github.com/gatsbyjs/gatsby).
32

4-
PRs should be made against the `build` branch. Upon merging, a maintainer will separately run the deploy scripts which commits a build version of the site to the `master` branch.
3+
This site is built with Eleventy and Tailwind.
4+
5+
PRs should be made against the `build` branch. Upon merging, a GitHub Action will build and deploy the site to the `master` branch.
56

67
## Prerequisites
8+
79
Install dependencies with `npm install`.
810

911
## Develop
10-
Run `npm run develop` and access the dev server at the address it reports.
12+
13+
Run `npm run start` and access the dev server at the address it reports.
1114

1215
## Build
13-
Run `npm build`, and a built version will be written to `/dist`. This will
14-
also update the markdown files that define our code of conduct, speaker
15-
questionnaire, and sponsorship levels from the [admin repository](https://github.com/javascriptmn/javascriptmn)
1616

17-
## Style
18-
This repository is configured to use [prettier](https://prettier.io/) on commit.
17+
Run `npm build`, and a built version will be written to `/dist`. You can run the built site in a web server, for example, `npx serve dist`.
18+
19+
Building for production minifies HTML, CSS, and JavaScript files as well as adds a cachebusting parameter to those resources.
20+
21+
## Events
1922

20-
It will lint and format your changes automatically, so don't worry about following
21-
format standards (so long as your code passes the lint-staged step).
23+
A list of events (past and upcoming) are stored in [src/globals/events.js](src/globals/events.js). The newest non-hidden event that is in the future will be treated as the featured upcoming event. A small amount of clientside JavaScript will automatically hide this event the day after it has occurred.

gatsby-browser.js

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

0 commit comments

Comments
 (0)