mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
fix(Docs): Add cache-control and default to HTML content (#43989)
This commit is contained in:
1 parent
1cde4de0dc
commit
04d08fbba7
2 files changed
+13
-2
No files matched your search
@@ -14,7 +14,10 @@ export async function GET(_request: Request, { params }: { params: Promise<{ slu
|
||||
try {
|
||||
const content = await fs.readFile(filePath, 'utf-8')
|
||||
return new NextResponse(content, {
|
||||
headers: { 'Content-Type': 'text/markdown; charset=utf-8' },
|
||||
headers: {
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=86400, stale-while-revalidate=3600',
|
||||
},
|
||||
})
|
||||
} catch {
|
||||
return new NextResponse('Not found', { status: 404 })
|
||||
|
||||
@@ -30,7 +30,15 @@ function AiTools({ className }: { className?: string }) {
|
||||
|
||||
try {
|
||||
const res = await fetch(mdUrl)
|
||||
const text = await res.text()
|
||||
let text: string
|
||||
|
||||
if (res.ok) {
|
||||
text = await res.text()
|
||||
} else {
|
||||
// Default to HTML content within the article when no .md file is available.
|
||||
text = document.getElementById('sb-docs-guide-main-article')?.innerHTML ?? ''
|
||||
}
|
||||
|
||||
await navigator.clipboard.writeText(text)
|
||||
setCopied(true)
|
||||
setTimeout(() => setCopied(false), 2000)
|
||||
|
||||
Reference in new issue
Block a user