Create pretty route for outfit images
This is mostly for decoupling's sake: I want pretty outfit URLs that aren't dependent on the `/api/outfitImage` path structure, so that we can serve them as ~permanent pretty URLs that don't actually indicate where or how the image is stored.
This commit is contained in:
parent
ae82a6236f
commit
0eec503b91
2 changed files with 13 additions and 7 deletions
|
@ -76,12 +76,14 @@ async function handle(req, res) {
|
|||
const updatedAtTimestamp = Math.floor(
|
||||
new Date(outfit.updatedAt).getTime() / 1000
|
||||
);
|
||||
const outfitUrl = `https://impress-2020.openneo.net/outfits/${encodeURIComponent(
|
||||
outfit.id
|
||||
)}`;
|
||||
const imageUrl = `https://impress-2020.openneo.net/api/outfitImage?size=600&id=${encodeURIComponent(
|
||||
outfit.id
|
||||
)}&updatedAt=${updatedAtTimestamp}`;
|
||||
const outfitUrl =
|
||||
`https://impress-2020.openneo.net/outfits` +
|
||||
`/${encodeURIComponent(outfit.id)}`;
|
||||
const imageUrl =
|
||||
`https://impress-2020.openneo.net/outfits` +
|
||||
`/${encodeURIComponent(outfit.id)}` +
|
||||
`/v/${encodeURIComponent(updatedAtTimestamp)}` +
|
||||
`/600.png`;
|
||||
const metaTags = `
|
||||
<meta property="og:title" content="${escapeHtml(outfit.name)}">
|
||||
<meta property="og:type" content="website">
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
{
|
||||
"routes": [
|
||||
{
|
||||
"src": "/outfits/(?<id>[^/]+)/v/(?<updatedAt>[^/]+)/(?<size>150|300|600).png",
|
||||
"dest": "/api/outfitImage.js?size=$size&id=$id&updatedAt=$updatedAt"
|
||||
},
|
||||
{ "src": "/outfits/new(\\?|$)", "dest": "/index.html" },
|
||||
{ "src": "/outfits/(?<id>[^/]*)", "dest": "/api/outfitPageSSR.js?id=$id" },
|
||||
{ "src": "/outfits/(?<id>[^/]+)", "dest": "/api/outfitPageSSR.js?id=$id" },
|
||||
{
|
||||
"handle": "filesystem"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue