mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-03 01:16:14 +03:00
Generate allImages list.
This commit is contained in:
parent
c8c7efc067
commit
e1ac97706d
@ -1,5 +1,5 @@
|
||||
const exposingList =
|
||||
"(application, PageRoute, all, pages, routeToString, Image, imageUrl, images)";
|
||||
"(application, PageRoute, all, pages, routeToString, Image, imageUrl, images, allImages)";
|
||||
|
||||
function staticRouteStuff(staticRoutes) {
|
||||
return `
|
||||
@ -21,6 +21,11 @@ ${staticRoutes.urlParser}
|
||||
|
||||
${staticRoutes.imageAssetsRecord}
|
||||
|
||||
allImages : List Image
|
||||
allImages =
|
||||
[${staticRoutes.allImages.join("\n , ")}
|
||||
]
|
||||
|
||||
routeToString : PageRoute -> String
|
||||
routeToString (PageRoute route) =
|
||||
"/"
|
||||
|
@ -101,7 +101,8 @@ function generate(scanned) {
|
||||
// routeToMetadata: formatCaseStatement("toMetadata", routeToMetadata),
|
||||
// routeToDocExtension: formatCaseStatement("toExt", routeToExt),
|
||||
// routeToSource: formatCaseStatement("toSourcePath", routeToSource),
|
||||
imageAssetsRecord: toElmRecord("images", getImageAssets(), true)
|
||||
imageAssetsRecord: toElmRecord("images", getImageAssets(), true),
|
||||
allImages: allImageAssetNames()
|
||||
};
|
||||
}
|
||||
function getImageAssets() {
|
||||
@ -123,6 +124,21 @@ function getImageAssets() {
|
||||
});
|
||||
return assetsRecord;
|
||||
}
|
||||
function allImageAssetNames() {
|
||||
return glob
|
||||
.sync("images/**/*", {})
|
||||
.filter(filePath => !fs.lstatSync(filePath).isDirectory())
|
||||
.map(relativeImagePath)
|
||||
.map(info => {
|
||||
return (
|
||||
"(Image [ " +
|
||||
info.fragmentsWithExtension
|
||||
.map(fragment => `"${fragment}"`)
|
||||
.join(", ") +
|
||||
" ])"
|
||||
);
|
||||
});
|
||||
}
|
||||
function toPascalCase(str) {
|
||||
var pascal = str.replace(/(\-\w)/g, function(m) {
|
||||
return m[1].toUpperCase();
|
||||
|
Loading…
Reference in New Issue
Block a user