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