Skip to content

Commit eec045a

Browse files
committed
docs: link to internal page for configuration
1 parent 86d2305 commit eec045a

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

docs/guides/hugo.md

+13-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ meta:
77
- itemprop: description
88
content: PurgeCSS can be used with Hugo via Hugo Pipes asset processing
99
- property: og:url
10-
content: https://purgecss.com/guides/hugo
10+
content: https://purgecss.com/guides/hugo
1111
- property: og:site_name
1212
content: purgecss.com
1313
- property: og:type
@@ -68,27 +68,23 @@ If it's not already there, add `node_modules/` to your `.gitignore` file.
6868
Create a `postcss.config.js` file at the project root with these contents:
6969

7070
```js
71-
const purgecss = require('@fullhuman/postcss-purgecss')({
72-
content: ['./hugo_stats.json'],
73-
defaultExtractor: content => {
71+
const purgecss = require("@fullhuman/postcss-purgecss")({
72+
content: ["./hugo_stats.json"],
73+
defaultExtractor: (content) => {
7474
const els = JSON.parse(content).htmlElements;
75-
return [
76-
...(els.tags || []),
77-
...(els.classes || []),
78-
...(els.ids || []),
79-
];
75+
return [...(els.tags || []), ...(els.classes || []), ...(els.ids || [])];
8076
},
81-
safelist: []
77+
safelist: [],
8278
});
8379
8480
module.exports = {
8581
plugins: [
86-
...(process.env.HUGO_ENVIRONMENT === 'production' ? [purgecss] : [])
87-
]
82+
...(process.env.HUGO_ENVIRONMENT === "production" ? [purgecss] : []),
83+
],
8884
};
8985
```
9086

91-
See the [PurgeCSS configuration docs](https://purgecss.com/configuration.html) for details on each option.
87+
See the [PurgeCSS configuration docs](../configuration.md) for details on each option.
9288

9389
**Note:** `safelist` is an empty array (for now). Remember, only elements from your HTML templates are extracted. So, if your JS adds elements, you'll need to safelist them.
9490

@@ -97,17 +93,15 @@ See the [PurgeCSS configuration docs](https://purgecss.com/configuration.html) f
9793
In the HTML Template for your `<head>`, add this:
9894

9995
```html
100-
{{ $css := resources.Get "css/style.css" | resources.PostCSS }}
101-
102-
{{ if hugo.IsProduction }}
103-
{{ $css = $css | minify | fingerprint | resources.PostProcess }}
104-
{{ end }}
96+
{{ $css := resources.Get "css/style.css" | resources.PostCSS }} {{ if
97+
hugo.IsProduction }} {{ $css = $css | minify | fingerprint |
98+
resources.PostProcess }} {{ end }}
10599
106100
<link
107101
rel="stylesheet"
108102
href="{{ $css.RelPermalink }}"
109103
integrity="{{ $css.Data.Integrity }}"
110-
>
104+
/>
111105
```
112106

113107
This assumes:

0 commit comments

Comments
 (0)