@@ -7,7 +7,11 @@ export default {
7
7
if ( url . pathname === '/version-warning.html' ) {
8
8
try {
9
9
const html = await versionWarning ( request , env )
10
- return new Response ( html , { headers : { 'Content-Type' : 'text/html' , 'Cache-Control' : 'max-age=1800' } } )
10
+ const headers = {
11
+ 'Content-Type' : 'text/plain' ,
12
+ 'Cache-Control' : 'max-age=2592000' , // 30 days
13
+ }
14
+ return new Response ( html , { headers } )
11
15
} catch ( e ) {
12
16
console . error ( e )
13
17
return new Response (
@@ -24,10 +28,10 @@ export default {
24
28
// env looks like
25
29
// {"CF_PAGES":"1","CF_PAGES_BRANCH":"ahead-warning","CF_PAGES_COMMIT_SHA":"...","CF_PAGES_URL":"https://..."}
26
30
async function versionWarning ( request , env ) {
27
- const headers = new Headers ( {
31
+ const headers = {
28
32
'User-Agent' : request . headers . get ( 'User-Agent' ) || 'pydantic-ai-docs' ,
29
33
'Accept' : 'application/vnd.github.v3+json' ,
30
- } )
34
+ }
31
35
const r1 = await fetch ( 'https://api.github.com/repos/pydantic/pydantic-ai/releases/latest' , { headers} )
32
36
if ( ! r1 . ok ) {
33
37
const text = await r1 . text ( )
@@ -55,7 +59,7 @@ async function versionWarning(request, env) {
55
59
<p class="admonition-title">Version Notice</p>
56
60
<p>
57
61
${ env . CF_PAGES_BRANCH === 'main' ? '' : `(<b>${ env . CF_PAGES_BRANCH } </b> preview)` }
58
- This documentation is ahead of the latest release by <b>${ ahead_by } </b> commit${ ahead_by === 1 ? '' : 's' } .
62
+ This documentation is ahead of the last release by <b>${ ahead_by } </b> commit${ ahead_by === 1 ? '' : 's' } .
59
63
You may see documentation for features not yet supported in the latest release <a href="${ html_url } ">${ name } </a>.
60
64
</p>
61
65
</div>`
0 commit comments