summaryrefslogtreecommitdiff
path: root/docs/src/pages/guides/deploy.md
diff options
context:
space:
mode:
authorGravatar Steve Murphy <93333985+Steve-B-Murphy@users.noreply.github.com> 2021-11-10 13:07:58 -0700
committerGravatar GitHub <noreply@github.com> 2021-11-10 14:07:58 -0600
commit3956bab271302fced12b527fbadb9ea6abad5ca5 (patch)
treed106c003c7fde97ddbdd61dff6b3154e5605149e /docs/src/pages/guides/deploy.md
parent48bad7bdc078451006e658ef6d976bba977cda98 (diff)
downloadastro-3956bab271302fced12b527fbadb9ea6abad5ca5.tar.gz
astro-3956bab271302fced12b527fbadb9ea6abad5ca5.tar.zst
astro-3956bab271302fced12b527fbadb9ea6abad5ca5.zip
Update deploy.md (#1781)
Co-authored-by: Caleb Jasik <calebjasik@jasik.xyz>
Diffstat (limited to 'docs/src/pages/guides/deploy.md')
-rw-r--r--docs/src/pages/guides/deploy.md89
1 files changed, 89 insertions, 0 deletions
diff --git a/docs/src/pages/guides/deploy.md b/docs/src/pages/guides/deploy.md
index 2f75af8bf..473566cd9 100644
--- a/docs/src/pages/guides/deploy.md
+++ b/docs/src/pages/guides/deploy.md
@@ -414,6 +414,95 @@ You can deploy your Astro project using [Buddy](https://buddy.works). To do so y
6. Add a deployment action - there are many to choose from, you can browse them [here](https://buddy.works/actions). Although their can settings differ, remember to set the **Source path** to `dist`.
7. Press the **Run** button.
+
+## Layer0
+You can deploy your Astro project using the steps in the following sections.
+
+### Create the Astro Site
+If you don't have an existing Astro site, you can create one by running:
+
+```bash
+# Make a new project directory, and navigate directly into it
+$ mkdir my-astro-project && cd $_
+
+# prepare for liftoff...
+$ npm init astro
+
+# install dependencies
+$ npm install
+
+# start developing!
+$ npm run dev
+
+# when you're ready: build your static site to `dist/`
+$ npm run build
+```
+
+### Add Layer0
+
+```bash
+# First, globally install the Layer0 CLI:
+$ npm i -g @layer0/cli
+
+# Then, add Layer0 to your Astro site:
+$ 0 init
+```
+
+### Update your Layer0 Router
+
+Paste the following into routes.ts:
+
+```js
+// routes.ts
+import { Router } from '@layer0/core'
+
+export default new Router()
+ .get('/:path*/:file.:ext(js|css|png|ico|jpg|gif|svg)', ({ cache, serveStatic }) => {
+ cache({
+ browser: {
+ // cache js, css, and images in the browser for one hour...
+ maxAgeSeconds: 60 * 60,
+ },
+ edge: {
+ // ... and at the edge for one year
+ maxAgeSeconds: 60 * 60 * 24 * 365,
+ },
+ })
+ serveStatic('dist/:path*/:file.:ext')
+ })
+ .match('/:path*', ({ cache, serveStatic, setResponseHeader }) => {
+ cache({
+ // prevent the browser from caching html...
+ browser: false,
+ edge: {
+ // ...cache html at the edge for one year
+ maxAgeSeconds: 60 * 60 * 24 * 365,
+ },
+ })
+ setResponseHeader('content-type', 'text/html; charset=UTF-8')
+ serveStatic('dist/:path*')
+ })
+```
+
+You can remove the origin backend from `layer0.config.js`:
+
+```js
+module.exports = {}
+```
+
+### Deploy to Layer0
+
+To deploy your site to Layer0, run:
+
+```bash
+# Create a production build of your astro site
+$ npm run build
+
+# Deploy it to Layer0
+$ 0 deploy
+```
+
+
## Credits
This guide was originally based off [Vite](https://vitejs.dev/)’s well-documented static deploy guide.