forked from netlify/edge-functions-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (29 loc) · 1023 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import repoLink from "../../components/repo-link.js";
export default {
title: "Hello world",
metaDescription: "Explore our library of edge function examples and deploy your own to Netlify.",
page: function () {
return `
<section>
<h1>Hello, world!</h1>
<p>
You can use Edge Functions to return a plain HTTP text/html response. In this example, we return the string "Hello, World!" as text/html.
</p>
<pre><code>export default async (request) => {
return new Response("Hello, World!", {
headers: { "content-type": "text/html" },
});
};</code></pre>
<h2>See this in action</h2>
<ul>
<li><a href="/hello">View the response from the Edge Function</a></li>
<li>${repoLink("hello.js")}</li>
</ul>
<div class="protip">
<h2>Pro tip!</h2>
<p>Need to return JSON data from an Edge Function? Check out the <a href="/example/json">JSON response</a> method on the Context object!</p>
</div>
</section>
`;
},
};