mirror of
https://github.com/dillonkearns/elm-pages.git
synced 2024-09-11 09:05:28 +03:00
Update adapter script.
This commit is contained in:
parent
7f35edd60e
commit
e835b494c9
@ -19,18 +19,18 @@ export default async function run({
|
||||
renderFunctionFilePath,
|
||||
"./functions/server-render/elm-pages-cli.js"
|
||||
);
|
||||
fs.copyFileSync(portsFilePath, "./functions/render/custom-backend-task.js");
|
||||
fs.copyFileSync(portsFilePath, "./functions/render/custom-backend-task.mjs");
|
||||
fs.copyFileSync(
|
||||
portsFilePath,
|
||||
"./functions/server-render/custom-backend-task.js"
|
||||
"./functions/server-render/custom-backend-task.mjs"
|
||||
);
|
||||
|
||||
fs.writeFileSync(
|
||||
"./functions/render/index.js",
|
||||
"./functions/render/index.mjs",
|
||||
rendererCode(true, htmlTemplate)
|
||||
);
|
||||
fs.writeFileSync(
|
||||
"./functions/server-render/index.js",
|
||||
"./functions/server-render/index.mjs",
|
||||
rendererCode(false, htmlTemplate)
|
||||
);
|
||||
// TODO rename functions/render to functions/fallback-render
|
||||
@ -128,12 +128,7 @@ export const handler = render;`
|
||||
async function render(event, context) {
|
||||
const requestTime = new Date();
|
||||
console.log(JSON.stringify(event));
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const compiledElmPath = path.join(__dirname, "elm-pages-cli.js");
|
||||
const compiledPortsFile = path.join(__dirname, "custom-backend-task.js");
|
||||
const compiledPortsFile = "./custom-backend-task.mjs";
|
||||
|
||||
try {
|
||||
const basePath = "/";
|
||||
@ -143,7 +138,7 @@ async function render(event, context) {
|
||||
const renderResult = await renderer.render(
|
||||
compiledPortsFile,
|
||||
basePath,
|
||||
(await import(path.resolve(compiledElmPath))).default,
|
||||
(await import("./elm-pages-cli.js")).default,
|
||||
mode,
|
||||
event.path,
|
||||
await reqToJson(event, requestTime),
|
||||
|
@ -2,8 +2,6 @@ import * as seo from "./seo-renderer.js";
|
||||
import * as packageJson from "../../package.json" assert { type: "json" };
|
||||
import * as path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const cliVersion = packageJson.version;
|
||||
|
||||
@ -27,6 +25,8 @@ export function wrapHtml(basePath, fromElm, contentDatPayload) {
|
||||
* @param {(context: {cliVersion: string;}) => string} userHeadTagsTemplate
|
||||
*/
|
||||
export function templateHtml(devMode, userHeadTagsTemplate) {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
return /* html */ `<!DOCTYPE html>
|
||||
<!-- ROOT --><html lang="en">
|
||||
<head>
|
||||
@ -81,4 +81,3 @@ export function replaceTemplate(processedTemplate, info) {
|
||||
.replace(/<!--\s*PLACEHOLDER_HTML\s* -->/, info.html)
|
||||
.replace(/<!-- ROOT -->\S*<html lang="en">/m, info.rootElement);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user