lightnet 3.12.0 → 3.12.2
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/CHANGELOG.md +22 -0
- package/__e2e__/admin.spec.ts +1 -365
- package/__e2e__/fixtures/basics/node_modules/.bin/astro +2 -2
- package/__e2e__/fixtures/basics/package.json +3 -3
- package/package.json +8 -15
- package/src/astro-integration/config.ts +1 -22
- package/src/astro-integration/integration.ts +4 -39
- package/src/content/content-schema.ts +0 -7
- package/src/content/get-media-items.ts +1 -47
- package/src/i18n/translate.ts +1 -1
- package/src/i18n/translations/TRANSLATION-STATUS.md +37 -12
- package/src/i18n/translations/en.yml +5 -0
- package/src/i18n/translations.ts +0 -7
- package/src/layouts/Page.astro +2 -0
- package/src/layouts/global.css +3 -0
- package/src/pages/details-page/components/main-details/EditButton.astro +2 -4
- package/src/pages/search-page/components/SearchFilter.tsx +1 -1
- package/src/admin/api/fs/write-file.ts +0 -53
- package/src/admin/components/form/DynamicArray.tsx +0 -129
- package/src/admin/components/form/Input.tsx +0 -68
- package/src/admin/components/form/LazyLoadedMarkdownEditor.tsx +0 -109
- package/src/admin/components/form/MarkdownEditor.tsx +0 -62
- package/src/admin/components/form/Select.tsx +0 -71
- package/src/admin/components/form/SubmitButton.tsx +0 -86
- package/src/admin/components/form/atoms/Button.tsx +0 -27
- package/src/admin/components/form/atoms/ErrorMessage.tsx +0 -13
- package/src/admin/components/form/atoms/FileUpload.tsx +0 -190
- package/src/admin/components/form/atoms/Hint.tsx +0 -19
- package/src/admin/components/form/atoms/Label.tsx +0 -37
- package/src/admin/components/form/hooks/use-field-dirty.tsx +0 -12
- package/src/admin/components/form/hooks/use-field-error.tsx +0 -34
- package/src/admin/components/form/utils/get-border-class.ts +0 -22
- package/src/admin/i18n/admin-i18n.ts +0 -21
- package/src/admin/i18n/translations/en.yml +0 -50
- package/src/admin/i18n/translations.ts +0 -5
- package/src/admin/pages/AdminRoute.astro +0 -14
- package/src/admin/pages/media/EditForm.tsx +0 -136
- package/src/admin/pages/media/EditRoute.astro +0 -100
- package/src/admin/pages/media/fields/Authors.tsx +0 -44
- package/src/admin/pages/media/fields/Categories.tsx +0 -49
- package/src/admin/pages/media/fields/Collections.tsx +0 -68
- package/src/admin/pages/media/fields/Content.tsx +0 -150
- package/src/admin/pages/media/fields/Image.tsx +0 -119
- package/src/admin/pages/media/file-system.ts +0 -41
- package/src/admin/pages/media/media-item-store.ts +0 -61
- package/src/admin/types/media-item.ts +0 -81
- package/src/api/media/[mediaId].ts +0 -16
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { type RefinementCtx, z } from "astro/zod"
|
|
2
|
-
import config from "virtual:lightnet/config"
|
|
3
|
-
|
|
4
|
-
const NON_EMPTY_STRING = "ln.admin.errors.non-empty-string"
|
|
5
|
-
const INVALID_DATE = "ln.admin.errors.invalid-date"
|
|
6
|
-
const REQUIRED = "ln.admin.errors.required"
|
|
7
|
-
const GTE_0 = "ln.admin.errors.gte-0"
|
|
8
|
-
const INTEGER = "ln.admin.errors.integer"
|
|
9
|
-
const UNIQUE_ELEMENTS = "ln.admin.errors.unique-elements"
|
|
10
|
-
const FILE_SIZE_EXCEEDED = "ln.admin.error.file-size-exceeded"
|
|
11
|
-
const NON_EMPTY_LIST = "ln.admin.errors.non-empty-list"
|
|
12
|
-
|
|
13
|
-
const unique = <TArrayItem>(path: Extract<keyof TArrayItem, string>) => {
|
|
14
|
-
return (values: TArrayItem[], ctx: RefinementCtx) => {
|
|
15
|
-
const seenValues = new Set<unknown>()
|
|
16
|
-
values.forEach((value, index) => {
|
|
17
|
-
if (seenValues.has(value[path])) {
|
|
18
|
-
ctx.addIssue({
|
|
19
|
-
path: [index, path],
|
|
20
|
-
message: UNIQUE_ELEMENTS,
|
|
21
|
-
code: "custom",
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
seenValues.add(value[path])
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const fileShape = z
|
|
30
|
-
.instanceof(File)
|
|
31
|
-
.optional()
|
|
32
|
-
.refine(
|
|
33
|
-
(file) =>
|
|
34
|
-
!file ||
|
|
35
|
-
!!(
|
|
36
|
-
file.size <
|
|
37
|
-
(config.experimental?.admin?.maxFileSize ?? 0) * 1024 * 1024
|
|
38
|
-
),
|
|
39
|
-
{ message: FILE_SIZE_EXCEEDED },
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
export const mediaItemSchema = z.object({
|
|
43
|
-
commonId: z.string().nonempty(NON_EMPTY_STRING),
|
|
44
|
-
title: z.string().nonempty(NON_EMPTY_STRING),
|
|
45
|
-
type: z.string().nonempty(REQUIRED),
|
|
46
|
-
language: z.string().nonempty(REQUIRED),
|
|
47
|
-
authors: z
|
|
48
|
-
.object({ value: z.string().nonempty(NON_EMPTY_STRING) })
|
|
49
|
-
.array()
|
|
50
|
-
.superRefine(unique("value")),
|
|
51
|
-
categories: z
|
|
52
|
-
.object({
|
|
53
|
-
value: z.string().nonempty(REQUIRED),
|
|
54
|
-
})
|
|
55
|
-
.array()
|
|
56
|
-
.superRefine(unique("value")),
|
|
57
|
-
collections: z
|
|
58
|
-
.object({
|
|
59
|
-
collection: z.string().nonempty(REQUIRED),
|
|
60
|
-
index: z.number().int(INTEGER).gte(0, GTE_0).optional(),
|
|
61
|
-
})
|
|
62
|
-
.array()
|
|
63
|
-
.superRefine(unique("collection")),
|
|
64
|
-
dateCreated: z.string().date(INVALID_DATE),
|
|
65
|
-
description: z.string().optional(),
|
|
66
|
-
image: z.object({
|
|
67
|
-
path: z.string().nonempty(NON_EMPTY_STRING),
|
|
68
|
-
previewSrc: z.string(),
|
|
69
|
-
file: fileShape,
|
|
70
|
-
}),
|
|
71
|
-
content: z
|
|
72
|
-
.object({
|
|
73
|
-
url: z.string().nonempty(NON_EMPTY_STRING),
|
|
74
|
-
file: fileShape,
|
|
75
|
-
label: z.string().optional(),
|
|
76
|
-
})
|
|
77
|
-
.array()
|
|
78
|
-
.min(1, NON_EMPTY_LIST),
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
export type MediaItem = z.input<typeof mediaItemSchema>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { APIRoute, GetStaticPaths } from "astro"
|
|
2
|
-
import { getCollection } from "astro:content"
|
|
3
|
-
|
|
4
|
-
import { getRawMediaItem } from "../../content/get-media-items"
|
|
5
|
-
|
|
6
|
-
export const getStaticPaths = (async () => {
|
|
7
|
-
const mediaItems = await getCollection("media")
|
|
8
|
-
return mediaItems.map(({ id: mediaId }) => ({ params: { mediaId } }))
|
|
9
|
-
}) satisfies GetStaticPaths
|
|
10
|
-
|
|
11
|
-
export const GET: APIRoute = async ({ params: { mediaId } }) => {
|
|
12
|
-
const entry = await getRawMediaItem(mediaId!)
|
|
13
|
-
return new Response(
|
|
14
|
-
JSON.stringify({ id: entry.id, content: entry.data }, null, 2),
|
|
15
|
-
)
|
|
16
|
-
}
|