Skip to content

Commit c6a4c34

Browse files
authored
Merge pull request #6 from cdeleeuwe/srcdir_option
Add srcdir option
2 parents bbfe8d7 + b0c908e commit c6a4c34

File tree

7 files changed

+17
-8
lines changed

7 files changed

+17
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ To install, add the following lines to your `netlify.toml` file:
2020
[plugins.inputs]
2121
# If it should show more verbose logs (optional, default = true)
2222
debug = true
23+
# Relative path to source directory in case you use Hugo's "--s" option
24+
srcdir = "path/to/website"
2325
```
2426

2527
Note: The `[[plugins]]` line is required for each plugin, even if you have other plugins in your `netlify.toml` file already.

example/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ imaging:
66
resampleFilter: Lanczos
77

88
params:
9-
amount: 500
9+
amount: 10

example/netlify.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[build]
22
publish = "public"
33
command = "hugo --gc --minify"
4+
ignore = "(exit 1)"
45

56
[build.environment]
67
HUGO_VERSION = "0.74.3"

index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
const getResourcesDir = () => {
2-
return 'resources';
1+
const { join } = require("path");
2+
3+
const getResourcesDir = ({ inputs }) => {
4+
return join(inputs.srcdir, 'resources');
35
}
46

57
const printList = (items) => {
@@ -12,8 +14,9 @@ const printList = (items) => {
1214
module.exports = {
1315

1416
async onPreBuild({ utils, inputs }) {
15-
const path = getResourcesDir();
17+
const path = getResourcesDir({ inputs });
1618
const success = await utils.cache.restore(path);
19+
console.log(`Checking if resources exist at "${path}"`);
1720

1821
if (success) {
1922
const cachedFiles = await utils.cache.list(path);
@@ -25,7 +28,7 @@ module.exports = {
2528
},
2629

2730
async onPostBuild({ utils, inputs }) {
28-
const path = getResourcesDir();
31+
const path = getResourcesDir({ inputs });
2932
const success = await utils.cache.save(path);
3033

3134
if (success) {

manifest.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ name: netlify-plugin-hugo-cache
22
inputs:
33
- name: debug
44
description: Show more verbose logs
5-
default: true
5+
default: true
6+
- name: srcdir
7+
description: Relative path to source directory in case you use Hugo's "--s" option
8+
default: ""

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netlify-plugin-hugo-cache-resources",
3-
"version": "0.1.6",
3+
"version": "0.2.0",
44
"description": "Persist Hugo resources folder between Netlify builds for huge build speed improvements!",
55
"main": "index.js",
66
"repository": "https://github.com/cdeleeuwe/netlify-plugin-hugo-cache-resources.git",

0 commit comments

Comments
 (0)