Skip to content

Commit 248286d

Browse files
authored
Feature/more caching (#1448)
* Cache social image * Update createMetaData to be async * Update usage of createMetaData * remove outdated comment * update handling of unstable_cache * Adjust caching on static pages * Use unstable_cache in loadMdxDirectory * Update mdx functions * Add bot blocking to edge function * remove revalidate from some routes * dependency upgrades
1 parent 93cd91e commit 248286d

File tree

36 files changed

+1253
-1135
lines changed

36 files changed

+1253
-1135
lines changed

netlify.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
[[plugins]]
77
package = "@netlify/plugin-nextjs"
88

9+
[[edge_functions]]
10+
function = "block-bots"
11+
path = "/*"
12+
913
[dev]
1014
command = "next dev"
1115
port = 9000
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// inspired (and taken) from ethan marcotte's blog post
2+
// https://ethanmarcotte.com/wrote/blockin-bots/
3+
const botUas = [
4+
'Amazonbot',
5+
'anthropic-ai',
6+
'Applebot-Extended',
7+
'Bytespider',
8+
'CCBot',
9+
'ChatGPT-User',
10+
'ClaudeBot',
11+
'Claude-Web',
12+
'cohere-ai',
13+
'DatadogSynthetics',
14+
'Diffbot',
15+
'DuckDuckBot',
16+
'FacebookBot',
17+
'FriendlyCrawler',
18+
'Google-Extended',
19+
'GoogleOther',
20+
'GoogleOther-Image',
21+
'GoogleOther-Video',
22+
'GPTBot',
23+
'ia_archiver',
24+
'ImagesiftBot',
25+
'img2dataset',
26+
'Meta-ExternalAgent',
27+
'OAI-SearchBot',
28+
'omgili',
29+
'omgilibot',
30+
'PerplexityBot',
31+
'search.marginalia.nu',
32+
'StractBot',
33+
'Trove',
34+
'Yandex',
35+
'YouBot',
36+
'AdsBot-Google',
37+
'Applebot',
38+
'AwarioRssBot',
39+
'AwarioSmartBot',
40+
'ChatGPT',
41+
'DataForSeoBot',
42+
'magpie-crawler',
43+
'Omgilibot',
44+
'peer39_crawler',
45+
];
46+
47+
export default async (request, context) => {
48+
const ua = request.headers.get('user-agent');
49+
50+
let isBot = false;
51+
52+
botUas.forEach((u) => {
53+
if (ua.toLowerCase().includes(u.toLowerCase())) {
54+
isBot = true;
55+
}
56+
});
57+
58+
const response = isBot
59+
? new Response(null, { status: 401 })
60+
: await context.next();
61+
return response;
62+
};

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"dependencies": {
2525
"@eslint/eslintrc": "^3.3.3",
26-
"@eslint/js": "^9.39.1",
26+
"@eslint/js": "^9.39.2",
2727
"@heroicons/react": "^2.2.0",
2828
"@imgix/js-core": "^3.8.0",
2929
"@mdx-js/loader": "^3.1.1",
@@ -36,18 +36,18 @@
3636
"calendar-link": "^2.11.0",
3737
"front-matter": "^4.0.2",
3838
"graphql": "^16.12.0",
39-
"graphql-request": "^7.3.5",
39+
"graphql-request": "^7.4.0",
4040
"hast-util-to-string": "^2.0.0",
4141
"hastscript": "^8.0.0",
4242
"leaflet": "^1.9.4",
4343
"leaflet.markercluster": "^1.5.3",
4444
"luxon": "^3.7.2",
4545
"markdown-it": "^13.0.2",
4646
"mdast-util-toc": "^7.1.0",
47-
"next": "^15.5.7",
47+
"next": "^15.5.9",
4848
"npm-watch": "^0.13.0",
49-
"react": "^19.2.1",
50-
"react-dom": "^19.2.1",
49+
"react": "^19.2.3",
50+
"react-dom": "^19.2.3",
5151
"react-leaflet": "^5.0.0",
5252
"react-leaflet-cluster": "^3.1.1",
5353
"rehype-autolink-headings": "^6.1.1",
@@ -65,11 +65,11 @@
6565
},
6666
"devDependencies": {
6767
"@faker-js/faker": "^10.1.0",
68-
"@netlify/plugin-nextjs": "^5.15.1",
68+
"@netlify/plugin-nextjs": "^5.15.3",
6969
"@types/leaflet": "^1.9.21",
7070
"@types/leaflet.markercluster": "^1.5.6",
7171
"@types/luxon": "^3.7.1",
72-
"@types/node": "^24.10.1",
72+
"@types/node": "^24.10.4",
7373
"@types/react": "^19.2.7",
7474
"@types/react-dom": "^19.2.3",
7575
"@types/require-dir": "^1.0.4",
@@ -78,13 +78,13 @@
7878
"concurrently": "^9.2.1",
7979
"cross-env": "^10.1.0",
8080
"esbuild": "^0.25.12",
81-
"eslint": "^9.39.1",
82-
"eslint-config-next": "^15.5.7",
83-
"netlify-cli": "^23.12.3",
81+
"eslint": "^9.39.2",
82+
"eslint-config-next": "^15.5.9",
83+
"netlify-cli": "^23.13.0",
8484
"postcss": "^8.5.6",
8585
"prettier": "^3.7.4",
86-
"sass": "^1.94.2",
87-
"tailwindcss": "^3.4.18",
86+
"sass": "^1.97.0",
87+
"tailwindcss": "^3.4.19",
8888
"tsx": "^4.21.0",
8989
"typescript": "^5.9.3"
9090
},

0 commit comments

Comments
 (0)