mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-26 05:13:24 +03:00
Write image-assets file.
This commit is contained in:
parent
5de1e17fd2
commit
1fb98e8650
@ -5,7 +5,7 @@ import Cli.Program as Program
|
|||||||
import String.Interpolate exposing (interpolate)
|
import String.Interpolate exposing (interpolate)
|
||||||
|
|
||||||
|
|
||||||
port writeFile : { rawContent : String, prerenderrc : String } -> Cmd msg
|
port writeFile : { rawContent : String, prerenderrc : String, imageAssets : String } -> Cmd msg
|
||||||
|
|
||||||
|
|
||||||
port printAndExitSuccess : String -> Cmd msg
|
port printAndExitSuccess : String -> Cmd msg
|
||||||
@ -130,6 +130,13 @@ init flags Default =
|
|||||||
{ rawContent =
|
{ rawContent =
|
||||||
generate { pages = flags.pages, posts = flags.posts }
|
generate { pages = flags.pages, posts = flags.posts }
|
||||||
, prerenderrc = preRenderRc { pages = flags.pages, posts = flags.posts }
|
, prerenderrc = preRenderRc { pages = flags.pages, posts = flags.posts }
|
||||||
|
, imageAssets = """export const imageAssets = {
|
||||||
|
"dillon2.jpg": require("../../images/dillon2.jpg"),
|
||||||
|
"article-cover/exit.jpg": require("../../images/article-cover/exit.jpg"),
|
||||||
|
"article-cover/mountains.jpg": require("../../images/article-cover/mountains.jpg"),
|
||||||
|
"article-cover/thinker.jpg": require("../../images/article-cover/thinker.jpg")
|
||||||
|
};
|
||||||
|
"""
|
||||||
}
|
}
|
||||||
|> writeFile
|
|> writeFile
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ function unpackFile(path: string) {
|
|||||||
|
|
||||||
const posts = glob.sync("_posts/**/*.emu", {}).map(unpackFile);
|
const posts = glob.sync("_posts/**/*.emu", {}).map(unpackFile);
|
||||||
const pages = glob.sync("_pages/**/*.emu", {}).map(unpackFile);
|
const pages = glob.sync("_pages/**/*.emu", {}).map(unpackFile);
|
||||||
|
const images = glob.sync("images/**/*", {});
|
||||||
|
|
||||||
let app = Elm.Main.init({
|
let app = Elm.Main.init({
|
||||||
flags: { argv: process.argv, versionMessage: version, posts, pages }
|
flags: { argv: process.argv, versionMessage: version, posts, pages }
|
||||||
@ -26,8 +27,14 @@ app.ports.printAndExitFailure.subscribe((message: string) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.ports.writeFile.subscribe(
|
app.ports.writeFile.subscribe(
|
||||||
(contents: { rawContent: string; prerenderrc: string }) => {
|
(contents: {
|
||||||
|
rawContent: string;
|
||||||
|
prerenderrc: string;
|
||||||
|
imageAssets: string;
|
||||||
|
}) => {
|
||||||
fs.writeFileSync("./gen/RawContent.elm", contents.rawContent);
|
fs.writeFileSync("./gen/RawContent.elm", contents.rawContent);
|
||||||
fs.writeFileSync("./.prerenderrc", contents.prerenderrc);
|
fs.writeFileSync("./.prerenderrc", contents.prerenderrc);
|
||||||
|
console.log("image assets", contents.imageAssets);
|
||||||
|
fs.writeFileSync("./src/js/image-assets.js", contents.imageAssets);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user