diff options
author | 2022-02-25 10:18:48 -0600 | |
---|---|---|
committer | 2022-02-25 08:18:48 -0800 | |
commit | c46db4ecbd1dfbe68679167b27e7f1d92e27f5fb (patch) | |
tree | b81ee82540b5ee6c5ac14e9b9a3cbe8c796a0858 /examples/non-html-pages/src | |
parent | 7680fd511882282be70785b42a62627876319eda (diff) | |
download | astro-c46db4ecbd1dfbe68679167b27e7f1d92e27f5fb.tar.gz astro-c46db4ecbd1dfbe68679167b27e7f1d92e27f5fb.tar.zst astro-c46db4ecbd1dfbe68679167b27e7f1d92e27f5fb.zip |
Add Non-HTML Pages example (#2637)
* Add Non-HTML Pages example
* Rename dir non-html-example to non-html-pages
* Update name to non-html-pages in package.json
Diffstat (limited to 'examples/non-html-pages/src')
-rw-r--r-- | examples/non-html-pages/src/pages/company.json.ts | 9 | ||||
-rw-r--r-- | examples/non-html-pages/src/pages/index.astro | 16 |
2 files changed, 25 insertions, 0 deletions
diff --git a/examples/non-html-pages/src/pages/company.json.ts b/examples/non-html-pages/src/pages/company.json.ts new file mode 100644 index 000000000..ecff4458e --- /dev/null +++ b/examples/non-html-pages/src/pages/company.json.ts @@ -0,0 +1,9 @@ +export async function get() { + return { + body: JSON.stringify({ + name: 'Astro', + url: 'https://astro.build/', + }), + }; +} + diff --git a/examples/non-html-pages/src/pages/index.astro b/examples/non-html-pages/src/pages/index.astro new file mode 100644 index 000000000..af1ed4326 --- /dev/null +++ b/examples/non-html-pages/src/pages/index.astro @@ -0,0 +1,16 @@ +--- +const url = `${Astro.request.canonicalURL.origin}/company.json`; +const response = await fetch(url); +const data = await response.json(); +--- +<html lang="en"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width" /> + <title>Astro</title> + </head> + <body> + <h1>Astro</h1> + <div>{JSON.stringify(data)}</div> + </body> +</html> |