@@ -4,6 +4,8 @@ const fs = require('fs')
44const getCacheDirs__ = ( base , input ) => {
55 let cacheDirs = [ ]
66
7+ if ( ! input ) return [ ]
8+
79 if ( typeof input === 'string' ) {
810 cacheDirs . push ( path . normalize ( base + '/' + input ) )
911 } else if ( Array . isArray ( input ) ) {
@@ -19,21 +21,21 @@ const getCacheDirs__ = (base, input) => {
1921
2022const getCacheDirs = ( base , inputs ) => {
2123 return [
22- ...getCacheDirs__ ( base , inputs . img_cache_local_dir ) ,
23- ...getCacheDirs__ ( base , inputs . img_cache_remote_dir ) ,
24- ...getCacheDirs__ ( base , inputs . other_cache_dir ) ,
24+ ...getCacheDirs__ ( base , inputs . cache_img ) ,
25+ ...getCacheDirs__ ( base , inputs . cache_assets ) ,
26+ ...getCacheDirs__ ( base , inputs . cache_other ) ,
2527 ]
2628}
2729
2830const getHttpHeaders = ( inputs ) => {
2931 let httpHeader = ''
3032
31- getCacheDirs__ ( '.' , inputs . img_cache_local_dir ) . map ( ( x ) => {
33+ getCacheDirs__ ( '.' , inputs . cache_img ) . map ( ( x ) => {
3234 httpHeader += `
3335${ x } /*
34- cache-control: public
35- cache-control: max-age=31536000
36- cache-control: immutable
36+ cache-control: public
37+ cache-control: max-age=31536000
38+ cache-control: immutable
3739
3840`
3941 } )
@@ -56,6 +58,12 @@ module.exports = {
5658 `Warning: directory ${ x } already exists before restoring caches. It will be replaced if it exists in the cache.` ,
5759 )
5860 }
61+
62+ if ( path . normalize ( x ) === path . normalize ( constants . PUBLISH_DIR ) ) {
63+ console . log (
64+ `11ty sites must publish the dist directory, but your site’s publish directory is set to : “${ constants . PUBLISH_DIR } ”.` ,
65+ )
66+ }
5967 } )
6068
6169 if ( await utils . cache . restore ( cacheDirs ) ) {
@@ -77,7 +85,7 @@ module.exports = {
7785 console . log ( '- ' + x )
7886 } )
7987
80- if ( inputs . img_cache_httpHeader ) {
88+ if ( inputs . cache_img_httpHeader ) {
8189 fs . appendFile (
8290 `${ constants . PUBLISH_DIR } /_headers` ,
8391 getHttpHeaders ( inputs ) ,
@@ -88,9 +96,7 @@ module.exports = {
8896 )
8997 }
9098 } else {
91- console . log (
92- `Warning: Unable to save 11ty cache. Build not found or is empty. Is you publish directory set correctly? “${ constants . PUBLISH_DIR } ”` ,
93- )
99+ console . log ( 'Did not save any folders to cache.' )
94100 }
95101 } ,
96102}
0 commit comments