mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 21:02:33 +03:00
Fix the way the elm-pages module was being loaded.
This commit is contained in:
parent
f8168edd69
commit
6ce8a8d0a2
@ -85,7 +85,7 @@ function webpackOptions(production, routes) {
|
||||
publicPath: "/"
|
||||
},
|
||||
resolve: {
|
||||
modules: [path.join(process.cwd(), "node_modules")],
|
||||
modules: [path.resolve(process.cwd(), `./node_modules`)],
|
||||
extensions: [".js", ".elm", ".scss", ".png", ".html"]
|
||||
},
|
||||
module: {
|
||||
|
48
index.js
48
index.js
@ -1 +1,47 @@
|
||||
console.log('Hello World!');
|
||||
module.exports = function pagesInit({ mainElmModule, imageAssets }) {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
let app = mainElmModule.init({
|
||||
flags: { imageAssets }
|
||||
});
|
||||
|
||||
app.ports.toJsPort.subscribe(headTags => {
|
||||
if (navigator.userAgent.indexOf("Headless") >= 0) {
|
||||
headTags.forEach(headTag => {
|
||||
appendTag(headTag);
|
||||
});
|
||||
}
|
||||
|
||||
appendTag({
|
||||
name: "link",
|
||||
attributes: [
|
||||
["rel", "apple-touch-icon"],
|
||||
["sizes", "180x180"],
|
||||
["href", "/apple-touch-icon-180x180.png"]
|
||||
]
|
||||
});
|
||||
appendTag({
|
||||
name: "link",
|
||||
attributes: [
|
||||
["rel", "apple-touch-icon"],
|
||||
["sizes", "1024x1024"],
|
||||
["href", "/apple-touch-icon-1024x1024.png"]
|
||||
]
|
||||
});
|
||||
|
||||
appendTag({
|
||||
name: "link",
|
||||
attributes: [["rel", "manifest"], ["href", "/manifest.webmanifest"]]
|
||||
});
|
||||
|
||||
document.dispatchEvent(new Event("prerender-trigger"));
|
||||
});
|
||||
});
|
||||
|
||||
function appendTag(tagDetails) {
|
||||
const meta = document.createElement(tagDetails.name);
|
||||
tagDetails.attributes.forEach(([name, value]) => {
|
||||
meta.setAttribute(name, value);
|
||||
});
|
||||
document.getElementsByTagName("head")[0].appendChild(meta);
|
||||
}
|
||||
};
|
||||
|
47
lib/index.js
47
lib/index.js
@ -1,47 +0,0 @@
|
||||
module.exports = function pagesInit({ mainElmModule, imageAssets }) {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
let app = mainElmModule.init({
|
||||
flags: { imageAssets }
|
||||
});
|
||||
|
||||
app.ports.toJsPort.subscribe(headTags => {
|
||||
if (navigator.userAgent.indexOf("Headless") >= 0) {
|
||||
headTags.forEach(headTag => {
|
||||
appendTag(headTag);
|
||||
});
|
||||
}
|
||||
|
||||
appendTag({
|
||||
name: "link",
|
||||
attributes: [
|
||||
["rel", "apple-touch-icon"],
|
||||
["sizes", "180x180"],
|
||||
["href", "/apple-touch-icon-180x180.png"]
|
||||
]
|
||||
});
|
||||
appendTag({
|
||||
name: "link",
|
||||
attributes: [
|
||||
["rel", "apple-touch-icon"],
|
||||
["sizes", "1024x1024"],
|
||||
["href", "/apple-touch-icon-1024x1024.png"]
|
||||
]
|
||||
});
|
||||
|
||||
appendTag({
|
||||
name: "link",
|
||||
attributes: [["rel", "manifest"], ["href", "/manifest.webmanifest"]]
|
||||
});
|
||||
|
||||
document.dispatchEvent(new Event("prerender-trigger"));
|
||||
});
|
||||
});
|
||||
|
||||
function appendTag(tagDetails) {
|
||||
const meta = document.createElement(tagDetails.name);
|
||||
tagDetails.attributes.forEach(([name, value]) => {
|
||||
meta.setAttribute(name, value);
|
||||
});
|
||||
document.getElementsByTagName("head")[0].appendChild(meta);
|
||||
}
|
||||
};
|
@ -2,7 +2,7 @@
|
||||
"name": "elm-pages",
|
||||
"version": "1.0.11",
|
||||
"description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
|
||||
"main": "./lib/index.js",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "cd generator && elm make src/Main.elm --output src/Main.js --optimize"
|
||||
},
|
||||
@ -47,6 +47,7 @@
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"index.js",
|
||||
"generator/bin/elm-pages",
|
||||
"generator/src/",
|
||||
"lib/manifest/index.js"
|
||||
|
Loading…
Reference in New Issue
Block a user