summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-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.
h=@astrojs/vue@4.0.0&id=9ef92e0a3d604c479bb325eab073e7d3c896d388&follow=1'>[ci] update github labelerGravatar Fred K. Schott 1-3/+0 2022-05-10[ci] update github labelerGravatar Fred K. Schott 1-1/+1 2022-05-10Fixing mobile header for docs example (#3335)Gravatar Tony Sullivan 2-5/+8 2022-05-10[ci] formatGravatar tony-sull 1-1/+1 2022-05-10Fixes custom 404 pages in astro dev (#3331)Gravatar Tony Sullivan 8-1/+89 2022-05-10rename dts to ts file (#3332)Gravatar Fred K. Schott 2-3/+8 2022-05-10[ci] collect statsGravatar FredKSchott 1-0/+1 2022-05-09[ci] collect statsGravatar FredKSchott 1-0/+1 2022-05-08[ci] collect statsGravatar FredKSchott 1-0/+1 2022-05-07[ci] collect statsGravatar FredKSchott 1-0/+1 2022-05-07docs: Update server options configuration reference (#3295)Gravatar Chris Swithinbank 1-6/+12 2022-05-06Fix tailwind integration in markdown files (#3305)Gravatar [object Object] 3-3/+3 2022-05-06[ci] release (#3308)astro@1.0.0-beta.27@astrojs/telemetry@0.1.2Gravatar github-actions[bot] 35-71/+77 2022-05-06[ci] formatGravatar matthewp 4-69/+103 2022-05-06Add new configKeys prop for telemetry (#3299)Gravatar Matthew Phillips 5-259/+518 2022-05-06[ci] collect statsGravatar FredKSchott 1-0/+1 2022-05-05Allowing Vite to handle base config for deploying to subpaths (#3178)Gravatar Tony Sullivan 4-3/+11 2022-05-05[ci] release (#3307)@astrojs/rss@0.2.0Gravatar github-actions[bot] 3-6/+7 2022-05-05Fix: make RSS canonicalUrl required (#3301)Gravatar Ben Holmes 4-37/+29 2022-05-05[ci] release (#3302)astro@1.0.0-beta.26Gravatar github-actions[bot] 33-67/+65 2022-05-05Revert "refactor: remove serialize-javascript (#3278)" (#3304)Gravatar Matthew Phillips 6-11/+21 2022-05-05[ci] formatGravatar matthewp 5-9/+11 2022-05-05Implement the Astro.response RFC (#3289)Gravatar Matthew Phillips 19-15/+177 2022-05-05[ci] release (#3293)astro@1.0.0-beta.25Gravatar github-actions[bot] 32-62/+63 2022-05-05[ci] collect statsGravatar FredKSchott 1-0/+1 2022-05-04[ci] formatGravatar matthewp 2-10/+10 2022-05-04Conform to API route signature (#3272)Gravatar Matthew Phillips 9-3/+179 2022-05-04fix: make congratsbot link to actual commit (#3292)Gravatar hippotastic 1-1/+1 2022-05-04readme fix (#3290)Gravatar Fred K. Schott 2-5/+2 2022-05-04[ci] release (#3288)astro@1.0.0-beta.24Gravatar github-actions[bot] 32-62/+63 2022-05-04[ci] formatGravatar matthewp 1-2/+12 2022-05-04feat: expose pages (#3286)Gravatar Pascal Schilp 4-4/+14 2022-05-04[ci] collect statsGravatar FredKSchott 1-0/+1 2022-05-03[ci] release (#3284)astro@1.0.0-beta.23@astrojs/turbolinks@0.1.2@astrojs/rss@0.1.1Gravatar github-actions[bot] 40-89/+88