create-nextjs-cms 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nextjs-cms",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"tsx": "^4.20.6",
|
|
30
30
|
"typescript": "^5.9.2",
|
|
31
31
|
"@lzcms/prettier-config": "0.1.0",
|
|
32
|
-
"@lzcms/
|
|
33
|
-
"@lzcms/
|
|
32
|
+
"@lzcms/tsconfig": "0.1.0",
|
|
33
|
+
"@lzcms/eslint-config": "0.3.0"
|
|
34
34
|
},
|
|
35
35
|
"prettier": "@lzcms/prettier-config",
|
|
36
36
|
"scripts": {
|
|
@@ -71,9 +71,7 @@ export async function GET(request: NextRequest) {
|
|
|
71
71
|
)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const fieldConfig = section.fields.find((field) => field.name === fieldName) as
|
|
75
|
-
| DocumentFieldConfigType
|
|
76
|
-
| undefined
|
|
74
|
+
const fieldConfig = section.fields.find((field) => field.name === fieldName) as DocumentFieldConfigType | undefined
|
|
77
75
|
|
|
78
76
|
if (!fieldConfig || typeof fieldConfig.build !== 'function') {
|
|
79
77
|
return NextResponse.json(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
2
|
|
|
3
3
|
const ProtectedDocument = ({
|
|
4
4
|
section,
|
|
@@ -15,60 +15,28 @@ const ProtectedDocument = ({
|
|
|
15
15
|
height: number
|
|
16
16
|
className?: string
|
|
17
17
|
}) => {
|
|
18
|
-
const [
|
|
19
|
-
const blobUrlRef = useRef<string | null>(null)
|
|
18
|
+
const [loading, setLoading] = useState(true)
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
name: file,
|
|
28
|
-
sectionName: section,
|
|
29
|
-
fieldName: fieldName,
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
const response = await fetch(`/api/document?${params.toString()}`, {
|
|
33
|
-
signal: controller.signal,
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
if (!response.ok) return
|
|
37
|
-
|
|
38
|
-
const blob = await response.blob()
|
|
39
|
-
const url = URL.createObjectURL(blob)
|
|
40
|
-
blobUrlRef.current = url
|
|
41
|
-
setSrcUrl(url)
|
|
42
|
-
} catch (error) {
|
|
43
|
-
// Ignore abort errors from cleanup
|
|
44
|
-
if (error instanceof DOMException && error.name === 'AbortError') return
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
fetchDocument()
|
|
49
|
-
|
|
50
|
-
return () => {
|
|
51
|
-
controller.abort()
|
|
52
|
-
if (blobUrlRef.current) {
|
|
53
|
-
URL.revokeObjectURL(blobUrlRef.current)
|
|
54
|
-
blobUrlRef.current = null
|
|
55
|
-
}
|
|
56
|
-
setSrcUrl(null)
|
|
57
|
-
}
|
|
58
|
-
}, [file, section, fieldName])
|
|
20
|
+
const params = new URLSearchParams({
|
|
21
|
+
name: file,
|
|
22
|
+
sectionName: section,
|
|
23
|
+
fieldName: fieldName,
|
|
24
|
+
})
|
|
25
|
+
const url = `/api/document?${params.toString()}`
|
|
59
26
|
|
|
60
27
|
return (
|
|
61
28
|
<div className={className}>
|
|
62
|
-
{
|
|
63
|
-
<embed
|
|
64
|
-
src={srcUrl}
|
|
65
|
-
className='max-w-full'
|
|
66
|
-
width={width}
|
|
67
|
-
height={height}
|
|
68
|
-
/>
|
|
69
|
-
) : (
|
|
29
|
+
{loading && (
|
|
70
30
|
<div className='animate-pulse bg-gray-500' style={{ width, height }} />
|
|
71
31
|
)}
|
|
32
|
+
<embed
|
|
33
|
+
src={url}
|
|
34
|
+
className='max-w-full'
|
|
35
|
+
width={width}
|
|
36
|
+
height={height}
|
|
37
|
+
onLoad={() => setLoading(false)}
|
|
38
|
+
style={loading ? { width: 0, height: 0, position: 'absolute' } : undefined}
|
|
39
|
+
/>
|
|
72
40
|
</div>
|
|
73
41
|
)
|
|
74
42
|
}
|