Created
December 11, 2022 20:16
-
-
Save handerson/4c1fd086e6323e47f797eb558c8bf261 to your computer and use it in GitHub Desktop.
collect all the files known to harp as an array. http://harpjs.com/recipes/print-debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% const flattenPublicJSON = (obj = {}, res = [], extraKey = '/') => { | |
for(key in obj){ | |
if(Array.isArray(obj[key])){ | |
flattenPublicJSON(obj[key], res, `${extraKey}`); | |
}else if(key === '_contents'){ | |
res.push(`${extraKey}/${obj[key]}`); | |
} else if(key === '_data'){ | |
//ignore | |
} else if(typeof obj[key] !== 'object'){ | |
res.push(`${extraKey}${obj[key]}`); | |
}else{ | |
flattenPublicJSON(obj[key], res, `${extraKey}${key}/`); | |
}; | |
}; | |
return res; | |
};%> | |
<pre><%- JSON.stringify(flattenPublicJSON(public), null, '\t') %></pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment