Skip to content

Commit

Permalink
Cache book covers for longer
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdoc committed Nov 7, 2022
1 parent 989a6c8 commit 83fc21a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/blog/2022/11ty-airtable.md
Expand Up @@ -39,7 +39,7 @@ The three packages we're using here are:
- **Airtable JS Library** - to do the heavy lifting of talking to Airtable and handling the response
- **dotenv** - so we don't have to hard code any API keys into our code.

```
```bash
npm install @11ty/eleventy-cache-assets airtable dotenv
```

Expand Down
9 changes: 6 additions & 3 deletions utils/shortcodes.js
Expand Up @@ -2,15 +2,18 @@ const eleventyImage = require("@11ty/eleventy-img");

module.exports = {
imgBookCover: async function (filepath, alt, widths, classes, sizes) {
if (!filepath) {
return;
}
if (!filepath) { return; }

let options = {
formats: ["webp", "jpg"],
widths: widths || [null],
urlPath: "/_assets/img/bookCovers/",
outputDir: "./dist/_assets/img/bookCovers/",
cacheOptions: {
duration: "2y",
directory: ".cache",
removeUrlQueryParams: false,
},
};

let stats = await eleventyImage(filepath, options);
Expand Down

0 comments on commit 83fc21a

Please sign in to comment.