Improve upload directories
This commit is contained in:
parent
65286f0c66
commit
1cda674782
|
@ -12,14 +12,14 @@ export const ContentThumbnails = buildCollectionConfig(
|
|||
singular: "Content Thumbnail",
|
||||
plural: "Content Thumbnails",
|
||||
},
|
||||
({ labels }) => ({
|
||||
({ uploadDir }) => ({
|
||||
defaultSort: fields.filename,
|
||||
admin: {
|
||||
useAsTitle: fields.filename,
|
||||
group: CollectionGroup.Media,
|
||||
},
|
||||
upload: {
|
||||
staticDir: `../uploads/${labels.plural}`,
|
||||
staticDir: uploadDir,
|
||||
mimeTypes: ["image/*"],
|
||||
imageSizes: [
|
||||
{
|
||||
|
|
|
@ -12,14 +12,14 @@ export const LibraryItemThumbnails = buildCollectionConfig(
|
|||
singular: "Library Item Thumbnail",
|
||||
plural: "Library Item Thumbnails",
|
||||
},
|
||||
({ labels }) => ({
|
||||
({ uploadDir }) => ({
|
||||
defaultSort: fields.filename,
|
||||
admin: {
|
||||
useAsTitle: fields.filename,
|
||||
group: CollectionGroup.Media,
|
||||
},
|
||||
upload: {
|
||||
staticDir: `../uploads/${labels.plural}`,
|
||||
staticDir: uploadDir,
|
||||
mimeTypes: ["image/*"],
|
||||
imageSizes: [
|
||||
{
|
||||
|
|
|
@ -12,14 +12,14 @@ export const PostThumbnails = buildCollectionConfig(
|
|||
singular: "Post Thumbnail",
|
||||
plural: "Post Thumbnails",
|
||||
},
|
||||
({ labels }) => ({
|
||||
({ uploadDir }) => ({
|
||||
defaultSort: fields.filename,
|
||||
admin: {
|
||||
useAsTitle: fields.filename,
|
||||
group: CollectionGroup.Media,
|
||||
},
|
||||
upload: {
|
||||
staticDir: `../uploads/${labels.plural}`,
|
||||
staticDir: uploadDir,
|
||||
mimeTypes: ["image/*"],
|
||||
imageSizes: [
|
||||
{
|
||||
|
|
|
@ -12,14 +12,14 @@ export const RecorderThumbnails = buildCollectionConfig(
|
|||
singular: "Recorder Thumbnail",
|
||||
plural: "Recorder Thumbnails",
|
||||
},
|
||||
({ labels }) => ({
|
||||
({ uploadDir }) => ({
|
||||
defaultSort: fields.filename,
|
||||
admin: {
|
||||
useAsTitle: fields.filename,
|
||||
group: CollectionGroup.Media,
|
||||
},
|
||||
upload: {
|
||||
staticDir: `../uploads/${labels.plural}`,
|
||||
staticDir: uploadDir,
|
||||
adminThumbnail: "small",
|
||||
mimeTypes: ["image/*"],
|
||||
imageSizes: [
|
||||
|
|
|
@ -31,7 +31,6 @@ export const Users = buildCollectionConfig(
|
|||
name: fields.recorder,
|
||||
type: "relationship",
|
||||
relationTo: Recorders.slug,
|
||||
required: true,
|
||||
admin: { width: "33%" },
|
||||
},
|
||||
{
|
||||
|
|
|
@ -4,8 +4,8 @@ import slugify from "slugify";
|
|||
export type BuildCollectionConfig = Omit<CollectionConfig, "slug" | "typescript" | "labels">;
|
||||
|
||||
export type GenerationFunctionProps = {
|
||||
labels: { singular: string; plural: string };
|
||||
slug: string;
|
||||
uploadDir: string;
|
||||
};
|
||||
|
||||
export const buildCollectionConfig = (
|
||||
|
@ -13,7 +13,8 @@ export const buildCollectionConfig = (
|
|||
generationFunction: (props: GenerationFunctionProps) => BuildCollectionConfig
|
||||
): CollectionConfig => {
|
||||
const slug = slugify(labels.plural, { lower: true, strict: true, trim: true });
|
||||
const config = generationFunction({ labels, slug });
|
||||
const uploadDir = `../uploads/${slug}`;
|
||||
const config = generationFunction({ slug, uploadDir });
|
||||
return {
|
||||
...config,
|
||||
slug,
|
||||
|
|
|
@ -4,4 +4,4 @@ export const shortenEllipsis = (text: string, length: number): string =>
|
|||
text.length - 3 > length ? `${text.substring(0, length)}...` : text;
|
||||
|
||||
export const formatLanguageCode = (code: string): string =>
|
||||
ISO6391.validate(code) ? ISO6391.getName(code) : code;
|
||||
ISO6391.validate(code) ? ISO6391.getName(code) : code;
|
||||
|
|
Loading…
Reference in New Issue