Skip to content

Commit 57ae9a8

Browse files
committed
chore: commit formats
1 parent 6639cbf commit 57ae9a8

File tree

8 files changed

+157
-87
lines changed

8 files changed

+157
-87
lines changed

.github/workflows/docs.yml

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
name: Deploy to Pages
22

33
on:
4-
push:
5-
branches: ['main']
6-
workflow_dispatch:
4+
push:
5+
branches: ['main']
6+
workflow_dispatch:
77

88
permissions:
9-
contents: read
10-
pages: write
11-
id-token: write
9+
contents: read
10+
pages: write
11+
id-token: write
1212

1313
concurrency:
14-
group: 'pages'
15-
cancel-in-progress: false
14+
group: 'pages'
15+
cancel-in-progress: false
1616

1717
env:
18-
BUILD_PATH: '.'
18+
BUILD_PATH: '.'
1919

2020
jobs:
21-
build:
22-
name: Build
23-
runs-on: ubuntu-latest
24-
steps:
25-
- name: Checkout
26-
uses: actions/checkout@v4
27-
- uses: pnpm/action-setup@v4
28-
with:
29-
version: 9
30-
- name: Setup Node
31-
uses: actions/setup-node@v4
32-
with:
33-
node-version: '20'
34-
cache: pnpm
35-
cache-dependency-path: pnpm-lock.yaml
36-
- name: Setup Pages
37-
id: pages
38-
uses: actions/configure-pages@v5
39-
- name: Install dependencies
40-
run: pnpm i --frozen-lockfile
41-
working-directory: ${{ env.BUILD_PATH }}
42-
- name: Build
43-
run: |
44-
pnpm build --pathprefix "${{ steps.pages.outputs.base_path }}"
45-
working-directory: ${{ env.BUILD_PATH }}
46-
- name: Upload artifact
47-
uses: actions/upload-pages-artifact@v3
48-
with:
49-
path: ${{ env.BUILD_PATH }}/_site
21+
build:
22+
name: Build
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
- uses: pnpm/action-setup@v4
28+
with:
29+
version: 9
30+
- name: Setup Node
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '20'
34+
cache: pnpm
35+
cache-dependency-path: pnpm-lock.yaml
36+
- name: Setup Pages
37+
id: pages
38+
uses: actions/configure-pages@v5
39+
- name: Install dependencies
40+
run: pnpm i --frozen-lockfile
41+
working-directory: ${{ env.BUILD_PATH }}
42+
- name: Build
43+
run: |
44+
pnpm build --pathprefix "${{ steps.pages.outputs.base_path }}"
45+
working-directory: ${{ env.BUILD_PATH }}
46+
- name: Upload artifact
47+
uses: actions/upload-pages-artifact@v3
48+
with:
49+
path: ${{ env.BUILD_PATH }}/_site
5050

51-
deploy:
52-
environment:
53-
name: github-pages
54-
url: ${{ steps.deployment.outputs.page_url }}
55-
needs: build
56-
runs-on: ubuntu-latest
57-
name: Deploy
58-
steps:
59-
- name: Deploy to GitHub Pages
60-
id: deployment
61-
uses: actions/deploy-pages@v4
51+
deploy:
52+
environment:
53+
name: github-pages
54+
url: ${{ steps.deployment.outputs.page_url }}
55+
needs: build
56+
runs-on: ubuntu-latest
57+
name: Deploy
58+
steps:
59+
- name: Deploy to GitHub Pages
60+
id: deployment
61+
uses: actions/deploy-pages@v4

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm nano-staged

.nano-staged.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import path, { join } from 'node:path'
2+
3+
export default api => {
4+
const actions = [prettify(api), packageSync(api)].filter(Boolean)
5+
return actions
6+
}
7+
8+
function prettify(api) {
9+
const prettierFiles = api.filenames
10+
.filter(file =>
11+
['.js', '.css', '.njk', '.html', '.json'].includes(path.extname(file))
12+
)
13+
.join(' ')
14+
return prettierFiles.length > 0 ? `prettier --write ${prettierFiles}` : ``
15+
}
16+
17+
function packageSync(api) {
18+
const hasPackageJSON = api.filenames
19+
.map(d => join(d.replace(process.cwd(), '.')))
20+
.some(d => d === 'package.json')
21+
return hasPackageJSON ? `pnpm dedupe` : null
22+
}

_plugins/purge.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
import { purgeCSSPlugin } from '@fullhuman/postcss-purgecss';
2-
import fs from 'fs';
3-
import postCSS from 'postcss';
4-
import glob from 'tiny-glob';
5-
import MinifyCSS from 'clean-css';
1+
import { purgeCSSPlugin } from '@fullhuman/postcss-purgecss'
2+
import fs from 'fs'
3+
import postCSS from 'postcss'
4+
import glob from 'tiny-glob'
5+
import MinifyCSS from 'clean-css'
66

7-
import { extname, join } from 'node:path';
7+
import { extname, join } from 'node:path'
88

99
export async function purgePlugin(eleventyConfig) {
1010
eleventyConfig.on(
1111
'eleventy.after',
1212
async ({ directories, results, runMode, outputMode }) => {
13-
await purge(directories);
13+
await purge(directories)
1414
}
15-
);
15+
)
1616
}
1717

1818
export async function purge(directories) {
19-
const inputDir = directories.output;
19+
const inputDir = directories.output
2020

2121
const requiredFiles = await glob('**/*.{html,css}', {
2222
cwd: join(process.cwd(), inputDir),
2323
absolute: true,
24-
});
24+
})
2525

26-
const cssFiles = [];
27-
const htmlFiles = [];
26+
const cssFiles = []
27+
const htmlFiles = []
2828

2929
for (let file of requiredFiles) {
3030
if (extname(file) === '.css') {
31-
cssFiles.push(file);
31+
cssFiles.push(file)
3232
}
3333
if (extname(file) === '.html') {
34-
htmlFiles.push(file);
34+
htmlFiles.push(file)
3535
}
3636
}
3737

3838
for (let file of cssFiles) {
39-
const sourceCSS = await fs.promises.readFile(file, 'utf8');
39+
const sourceCSS = await fs.promises.readFile(file, 'utf8')
4040
const allCSS = await postCSS([
4141
purgeCSSPlugin({
4242
content: htmlFiles,
4343
variables: true,
4444
keyframes: true,
45-
defaultExtractor: (content) => content.match(/[\w-:./]+(?<!:)/g) || [],
45+
defaultExtractor: content => content.match(/[\w-:./]+(?<!:)/g) || [],
4646
}),
4747
])
4848
.process(sourceCSS, {
4949
from: file,
5050
to: file,
5151
})
52-
.catch((error) => {
53-
console.log(error);
54-
});
52+
.catch(error => {
53+
console.log(error)
54+
})
5555

56-
const minifiedCSS = new MinifyCSS().minify(allCSS.css).styles;
57-
await fs.promises.writeFile(file, minifiedCSS, 'utf8');
56+
const minifiedCSS = new MinifyCSS().minify(allCSS.css).styles
57+
await fs.promises.writeFile(file, minifiedCSS, 'utf8')
5858
}
5959
}

eleventy.config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { EleventyHtmlBasePlugin } from '@11ty/eleventy';
2-
import { purgePlugin } from './_plugins/purge.js';
1+
import { EleventyHtmlBasePlugin } from '@11ty/eleventy'
2+
import { purgePlugin } from './_plugins/purge.js'
33

4-
import criticalCss from 'eleventy-critical-css';
4+
import criticalCss from 'eleventy-critical-css'
55

66
export default function (eleventyConfig) {
7-
eleventyConfig.addPlugin(criticalCss);
7+
eleventyConfig.addPlugin(criticalCss)
88
eleventyConfig.addPassthroughCopy({
99
'./public/': '/',
10-
});
10+
})
1111
eleventyConfig.addPassthroughCopy({
1212
'./node_modules/shed-css/dist/index.css':
1313
'/node_modules/shed-css/dist/index.css',
14-
});
15-
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
16-
eleventyConfig.addPlugin(purgePlugin);
14+
})
15+
eleventyConfig.addPlugin(EleventyHtmlBasePlugin)
16+
eleventyConfig.addPlugin(purgePlugin)
1717
}

package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
{
22
"name": "tinytownstudio.github.io",
33
"version": "1.0.0",
4+
"description": "",
5+
"keywords": [],
6+
"license": "ISC",
7+
"author": "",
8+
"type": "module",
49
"main": "index.js",
510
"scripts": {
11+
"build": "eleventy",
612
"dev": "eleventy --serve",
7-
"build": "eleventy"
13+
"prepare": "husky"
814
},
9-
"keywords": [],
10-
"author": "",
11-
"license": "ISC",
12-
"description": "",
13-
"type": "module",
15+
"prettier": "@barelyhuman/prettier-config",
1416
"devDependencies": {
1517
"@11ty/eleventy": "^3.0.0",
16-
"clean-css": "^5.3.3",
17-
"shed-css": "^1.4.0",
18+
"@barelyhuman/prettier-config": "^2.0.2",
1819
"@fullhuman/postcss-purgecss": "^7.0.2",
20+
"clean-css": "^5.3.3",
1921
"eleventy-plugin-purgecss": "^0.5.0",
22+
"husky": "^9.1.7",
23+
"nano-staged": "^0.8.0",
2024
"postcss": "^8.5.1",
25+
"prettier": "^3.4.2",
26+
"shed-css": "^1.4.0",
2127
"tiny-glob": "^0.2.9"
2228
}
2329
}

pnpm-lock.yaml

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)