@astrojs/deno
Advanced tools
Comparing version 1.0.0 to 1.0.1
# @astrojs/node | ||
## 1.0.1 | ||
### Patch Changes | ||
- [#4558](https://github.com/withastro/astro/pull/4558) [`742966456`](https://github.com/withastro/astro/commit/7429664566f05ecebf6d57906f950627e62e690c) Thanks [@tony-sull](https://github.com/tony-sull)! - Adding the `withastro` keyword to include the adapters on the [Integrations Catalog](https://astro.build/integrations) | ||
* [#4562](https://github.com/withastro/astro/pull/4562) [`294122b4e`](https://github.com/withastro/astro/commit/294122b4e423107bd9d4854a266f029acbe5e293) Thanks [@zicklag](https://github.com/zicklag)! - Make Deno SSR Backend Render Custom 404 Pages | ||
## 1.0.0 | ||
@@ -43,3 +51,3 @@ | ||
```astro | ||
<div>Your address {Astro.clientAddress}</div> | ||
``` | ||
@@ -46,0 +54,0 @@ |
@@ -21,3 +21,8 @@ import { App } from "astro/app"; | ||
const localPath = new URL("." + url.pathname, clientRoot); | ||
return fetch(localPath.toString()); | ||
const fileResp = await fetch(localPath.toString()); | ||
if (fileResp.status == 404) { | ||
return await app.render(request); | ||
} else { | ||
return fileResp; | ||
} | ||
}; | ||
@@ -24,0 +29,0 @@ const port = options.port ?? 8085; |
{ | ||
"name": "@astrojs/deno", | ||
"description": "Deploy your site to a Deno server", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"type": "module", | ||
@@ -15,2 +15,3 @@ "types": "./dist/index.d.ts", | ||
"keywords": [ | ||
"withastro", | ||
"astro-adapter" | ||
@@ -29,3 +30,3 @@ ], | ||
"devDependencies": { | ||
"astro": "1.0.0", | ||
"astro": "1.1.3", | ||
"astro-scripts": "0.0.7" | ||
@@ -32,0 +33,0 @@ }, |
@@ -32,5 +32,17 @@ // Normal Imports | ||
// If the request path wasn't found in astro, | ||
// try to fetch a static file instead | ||
const url = new URL(request.url); | ||
const localPath = new URL('.' + url.pathname, clientRoot); | ||
return fetch(localPath.toString()); | ||
const fileResp = await fetch(localPath.toString()); | ||
// If the static file can't be found | ||
if (fileResp.status == 404) { | ||
// Render the astro custom 404 page | ||
return await app.render(request); | ||
// If the static file is found | ||
} else { | ||
return fileResp; | ||
} | ||
}; | ||
@@ -37,0 +49,0 @@ |
@@ -30,2 +30,17 @@ import { runBuildAndStartApp } from './helpers.js'; | ||
Deno.test({ | ||
name: 'Custom 404', | ||
async fn() { | ||
await startApp(async () => { | ||
const resp = await fetch('http://127.0.0.1:8085/this-does-not-exist'); | ||
assertEquals(resp.status, 404); | ||
const html = await resp.text(); | ||
assert(html); | ||
const doc = new DOMParser().parseFromString(html, `text/html`); | ||
const header = doc.querySelector('#custom-404'); | ||
assert(header, 'displays custom 404'); | ||
}); | ||
}, | ||
}); | ||
Deno.test({ | ||
name: 'Loads style assets', | ||
@@ -63,1 +78,29 @@ async fn() { | ||
}); | ||
Deno.test({ | ||
name: 'Works with Markdown', | ||
async fn() { | ||
await startApp(async () => { | ||
const resp = await fetch('http://127.0.0.1:8085/markdown'); | ||
const html = await resp.text(); | ||
const doc = new DOMParser().parseFromString(html, `text/html`); | ||
const h1 = doc.querySelector('h1'); | ||
assertEquals(h1.innerText, 'Heading from Markdown'); | ||
}); | ||
}, | ||
}); | ||
Deno.test({ | ||
name: 'Works with MDX', | ||
async fn() { | ||
await startApp(async () => { | ||
const resp = await fetch('http://127.0.0.1:8085/mdx'); | ||
const html = await resp.text(); | ||
const doc = new DOMParser().parseFromString(html, `text/html`); | ||
const h1 = doc.querySelector('h1'); | ||
assertEquals(h1.innerText, 'Heading from MDX'); | ||
}); | ||
}, | ||
}); |
@@ -9,2 +9,3 @@ { | ||
"@astrojs/react": "workspace:*", | ||
"@astrojs/mdx": "workspace:*", | ||
"react": "^18.1.0", | ||
@@ -11,0 +12,0 @@ "react-dom": "^18.1.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34534
29
519
15