mirror of
https://github.com/BradNut/awesome-uses
synced 2025-09-08 17:40:31 +00:00
fix build
This commit is contained in:
parent
9c2e3c5926
commit
585e6088fa
3 changed files with 30 additions and 23 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/*"
|
from = "/*"
|
||||||
to = "/.netlify/functions/server"
|
to = "/.netlify/edge-functions/server"
|
||||||
status = 200
|
status = 200
|
||||||
|
|
||||||
[[headers]]
|
[[headers]]
|
||||||
|
|
|
||||||
|
|
@ -30,22 +30,22 @@ export default async function handleRequest(
|
||||||
responseHeaders: Headers,
|
responseHeaders: Headers,
|
||||||
remixContext: EntryContext
|
remixContext: EntryContext
|
||||||
) {
|
) {
|
||||||
// // check if we have a cached response in memory
|
// check if we have a cached response in memory
|
||||||
// const cachedResponse = cache.get(request.url);
|
const cachedResponse = cache.get(request.url);
|
||||||
// if (cachedResponse) {
|
if (cachedResponse) {
|
||||||
// console.log('Serving from cache', request.url);
|
console.log('Serving from cache', request.url);
|
||||||
// // if we have a cached response, check if it's less than 5 seconds old
|
// if we have a cached response, check if it's less than 5 seconds old
|
||||||
// const now = new Date();
|
const now = new Date();
|
||||||
// const diff = now.getTime() - cachedResponse.date.getTime();
|
const diff = now.getTime() - cachedResponse.date.getTime();
|
||||||
// if (true || diff < 5000) {
|
if (true || diff < 5000) {
|
||||||
// // if it's less than 5 seconds old, return the cached response
|
// if it's less than 5 seconds old, return the cached response
|
||||||
// responseHeaders.set('Content-Type', 'text/html');
|
responseHeaders.set('Content-Type', 'text/html');
|
||||||
// return new Response(cachedResponse.html, {
|
return new Response(cachedResponse.html, {
|
||||||
// headers: responseHeaders,
|
headers: responseHeaders,
|
||||||
// status: responseStatusCode,
|
status: responseStatusCode,
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
let didError = false;
|
let didError = false;
|
||||||
const chunks: Uint8Array[] = [];
|
const chunks: Uint8Array[] = [];
|
||||||
|
|
@ -60,10 +60,15 @@ export default async function handleRequest(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// tee the stream so we can cache it and send it to the client
|
||||||
const [toReponse, toCache] = body.tee();
|
const [toReponse, toCache] = body.tee();
|
||||||
|
|
||||||
streamToText(toCache).then(html => {
|
streamToText(toCache).then(html => {
|
||||||
console.log('I have the HTML!', html.length);
|
console.log('Caching', request.url);
|
||||||
|
cache.set(request.url, {
|
||||||
|
html: html.replace('Rendered Fresh',`Rendered from cache ${new Date().toISOString()}`),
|
||||||
|
date: new Date(),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const headers = new Headers(responseHeaders);
|
const headers = new Headers(responseHeaders);
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ export function tags() {
|
||||||
const counts = allTags.reduce(countInstances, {});
|
const counts = allTags.reduce(countInstances, {});
|
||||||
// sort and filter for any tags that only have 1
|
// sort and filter for any tags that only have 1
|
||||||
const tags = Object.entries(counts)
|
const tags = Object.entries(counts)
|
||||||
.sort(([, countA], [, countB]) => countB - countA)
|
|
||||||
// Only show the tag if this topic has 3 or more people in it
|
// Only show the tag if this topic has 3 or more people in it
|
||||||
.filter(([, count]) => count >= 3)
|
.filter(([, count]) => count >= 3)
|
||||||
.map(([name, count]) => ({ name, count }));
|
.map(([name, count]) => ({ name, count }));
|
||||||
|
|
@ -85,8 +84,11 @@ export function tags() {
|
||||||
delete lowercaseTagMap[normalizedName];
|
delete lowercaseTagMap[normalizedName];
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, [])
|
||||||
|
// Sort by name first
|
||||||
|
.sort((a, b) => b.name.toLowerCase() > a.name.toLowerCase())
|
||||||
|
// Sort by count
|
||||||
|
.sort((a, b) => b.count - a.count);
|
||||||
return [{ name: 'all', count: people.length }, ...normalizedTags];
|
return [{ name: 'all', count: people.length }, ...normalizedTags];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,12 +118,12 @@ const normalizedTagMap = tags().reduce((acc, tag) => {
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
export function getPeople(tag?: string) {
|
export function getPeople(tag?: string) {
|
||||||
return people
|
return [...people]
|
||||||
.sort(() => Math.random() - 0.5)
|
.sort(() => Math.random() - 0.5)
|
||||||
.map((person) => {
|
.map((person) => {
|
||||||
const normalizedPerson = {
|
const normalizedPerson = {
|
||||||
...person,
|
...person,
|
||||||
// Clean out people that added basically the same tags twice
|
// Clean out people that added basically the same tags twice
|
||||||
tags: unique(
|
tags: unique(
|
||||||
person.tags.map((tag) => normalizedTagMap[normalizeTag(tag)] || tag)
|
person.tags.map((tag) => normalizedTagMap[normalizeTag(tag)] || tag)
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue