diff options
author | 2021-04-05 14:18:09 -0400 | |
---|---|---|
committer | 2021-04-05 14:18:09 -0400 | |
commit | c9bc6ffef7be0e068acb1b36475c4ab3d12fd5d5 (patch) | |
tree | d444fa26d0ce47bb3cebb5e6264d67778a2e106d /src/build.ts | |
parent | d9733e8d42662d8708b5fc3bcb5c6c4db75df043 (diff) | |
download | astro-c9bc6ffef7be0e068acb1b36475c4ab3d12fd5d5.tar.gz astro-c9bc6ffef7be0e068acb1b36475c4ab3d12fd5d5.tar.zst astro-c9bc6ffef7be0e068acb1b36475c4ab3d12fd5d5.zip |
Improve searching for pages (#60)
This improves the algorithm for searching for pages. It now works like:
1. If pathname ends with /
1. Look for PATHNAME/index.astro
1. Look for PATHNAME/index.md
1. else
1. Look for PATHNAME.astro
1. Look for PATHNAME.md
1. Look for PATHNAME/index.astro
1. 301
1. Look for PATHNAME/index.md
1. 301
1. 404
Diffstat (limited to '')
-rw-r--r-- | src/build.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/build.ts b/src/build.ts index 831d0be0e..aef96b918 100644 --- a/src/build.ts +++ b/src/build.ts @@ -44,9 +44,10 @@ async function writeFilep(outPath: URL, bytes: string | Buffer, encoding: 'utf-8 /** Utility for writing a build result to disk */ async function writeResult(result: LoadResult, outPath: URL, encoding: null | 'utf-8') { - if (result.statusCode !== 200) { - error(logging, 'build', result.error || result.statusCode); - //return 1; + if (result.statusCode === 500 || result.statusCode === 404) { + error(logging, 'build', result.error || result.statusCode); + } else if(result.statusCode !== 200) { + error(logging, 'build', `Unexpected load result (${result.statusCode}) for ${outPath.pathname}`); } else { const bytes = result.contents; await writeFilep(outPath, bytes, encoding); |