Created
June 29, 2021 17:29
-
-
Save robdodson/e223a02a02859d28d555229cd9a73245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (config) { | |
config.addPlugin(EleventyServerlessBundlerPlugin, { | |
name: 'possum', // The serverless function name from your permalink object | |
functionsDir: './functions/', | |
}); | |
return { | |
dir: { | |
input: 'src/site/content/', // we use a string path with the forward slash since windows doesn't like the paths generated from path.join | |
output: 'dist', | |
data: '../_data', | |
includes: '../_includes', | |
}, | |
templateFormats: ['njk', 'md'], | |
htmlTemplateEngine: 'njk', | |
markdownTemplateEngine: 'njk', | |
// Because eleventy's passthroughFileCopy does not work with permalinks | |
// we need to manually copy assets ourselves using gulp. | |
// https://github.com/11ty/eleventy/issues/379 | |
passthroughFileCopy: false, | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"hosting": { | |
"public": "dist", | |
"rewrites": [{ | |
"source": "/possum", | |
"function": "possum" | |
}] | |
}, | |
"emulators": { | |
"hosting": { | |
"port": 8080 | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /functions/index.js | |
const possum = require('./possum'); | |
exports.possum = possum.possum; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /functions/possum/index.js | |
const functions = require('firebase-functions'); | |
const {EleventyServerless} = require('@11ty/eleventy'); | |
// // Create and Deploy Your First Cloud Functions | |
// // https://firebase.google.com/docs/functions/write-firebase-functions | |
exports.possum = functions.https.onRequest(async (request, response) => { | |
functions.logger.info('Hello logs!', {structuredData: true}); | |
// return response.send(`You requested path: ${request.path}`); | |
const elev = new EleventyServerless('serverless', { | |
path: request.path, // required, the URL path | |
}); | |
try { | |
// returns the HTML for the Eleventy template that matches to the URL | |
const html = await elev.render(); | |
return response.send(html); | |
} catch (e) { | |
return response.status(500).send(JSON.stringify({error: e.message})); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
layout: default | |
title: About | |
permalink: | |
possum: /about/ | |
--- | |
It's our about page! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment