-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
48 lines (41 loc) · 1.4 KB
/
next.config.ts
File metadata and controls
48 lines (41 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import type { NextConfig } from "next";
import type { RemotePattern } from 'next/dist/shared/lib/image-config';
const isStaticExport = process.env.STATIC_EXPORT === 'true'
const remotePatterns: RemotePattern[] = [
{ protocol: 'https', hostname: 'images.unsplash.com', pathname: '/**' },
{ protocol: 'https', hostname: 'i.ytimg.com', pathname: '/**' },
{ protocol: 'https', hostname: 'img.youtube.com', pathname: '/**' },
{ protocol: 'https', hostname: 'avatars.githubusercontent.com', pathname: '/**' },
{ protocol: 'https', hostname: 'lh3.googleusercontent.com', pathname: '/**' },
]
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL
if (supabaseUrl) {
try {
const { hostname } = new URL(supabaseUrl)
if (hostname) {
remotePatterns.push({ protocol: 'https', hostname, pathname: '/**' })
}
} catch {
// ignore invalid Supabase URL and fall back to the default remote patterns
}
}
const nextConfig: NextConfig = {
...(isStaticExport
? {
output: 'export',
// Ensure trailing slashes for consistent routing during static export
trailingSlash: true,
}
: {}),
// Set the base path if your site will be deployed to a subdirectory
// basePath: '/syntaxblogs',
images: isStaticExport
? {
unoptimized: true,
}
: {
remotePatterns,
formats: ['image/avif', 'image/webp'],
},
}
export default nextConfig;