mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Fix lint
This commit is contained in:
parent
c8dd7c718d
commit
8898965e06
1 changed files with 46 additions and 69 deletions
|
@ -14,28 +14,6 @@ type Attachment = {
|
||||||
mediaType: 'image/jpeg' | 'image/png' | 'image/gif' | 'video/mp4' | 'video/webm' | 'audio/mpeg' | 'audio/ogg' | null;
|
mediaType: 'image/jpeg' | 'image/png' | 'image/gif' | 'video/mp4' | 'video/webm' | 'audio/mpeg' | 'audio/ogg' | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
type Post = {
|
|
||||||
id: URL;
|
|
||||||
url: URL;
|
|
||||||
|
|
||||||
type: 'Note' | 'Article';
|
|
||||||
|
|
||||||
name: string;
|
|
||||||
content: string;
|
|
||||||
preview: { content: string } | null;
|
|
||||||
liked: boolean;
|
|
||||||
published: Date;
|
|
||||||
author: {
|
|
||||||
name: string;
|
|
||||||
username: string;
|
|
||||||
url: URL;
|
|
||||||
avatar: URL;
|
|
||||||
};
|
|
||||||
attachment: null | Attachment | Attachment[];
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
type AttachmentResult = null | Attachment | [Attachment, Attachment, ...Attachment[]]
|
type AttachmentResult = null | Attachment | [Attachment, Attachment, ...Attachment[]]
|
||||||
|
|
||||||
function toAttachment(value: unknown): Attachment | null {
|
function toAttachment(value: unknown): Attachment | null {
|
||||||
|
@ -147,10 +125,10 @@ function FeedAttachment({object, layout}: {object: ObjectProperties, layout: 'mo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(attachment)) {
|
if (Array.isArray(attachment)) {
|
||||||
return <MultipleAttachment attachments={attachment} layout={layout} />
|
return <MultipleAttachment attachments={attachment} layout={layout} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <SingleAttachment attachment={attachment} object={object} />
|
return <SingleAttachment attachment={attachment} object={object} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SingleInboxAttachment({attachment, object}: {attachment: Attachment, object: ObjectProperties}) {
|
function SingleInboxAttachment({attachment, object}: {attachment: Attachment, object: ObjectProperties}) {
|
||||||
|
@ -212,7 +190,7 @@ function InboxAttachment({object}: {object: ObjectProperties}) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <SingleInboxAttachment attachment={attachment} object={object}/>
|
return <SingleInboxAttachment attachment={attachment} object={object}/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimestamp(published: Date) {
|
function getTimestamp(published: Date) {
|
||||||
|
@ -368,14 +346,14 @@ function ItemHeading({children}: {children?: string }) {
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Heading className='my-1 leading-tight' level={5} data-test-activity-heading>{children[0]}</Heading>
|
<Heading className='my-1 leading-tight' level={5} data-test-activity-heading>{children[0]}</Heading>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function FeedLayoutArticleContent({object}: {object: ObjectProperties}) {
|
function FeedLayoutArticleContent({object}: {object: ObjectProperties}) {
|
||||||
const content = object.preview ? object.preview.content : <div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div>
|
const content = object.preview ? object.preview.content : <div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div>;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FeedAttachment object={object} layout={null} />
|
<FeedAttachment layout={null} object={object} />
|
||||||
<ItemHeading>
|
<ItemHeading>
|
||||||
{object.name}
|
{object.name}
|
||||||
</ItemHeading>
|
</ItemHeading>
|
||||||
|
@ -399,17 +377,17 @@ function FeedLayoutNoteContent({object}: {object: ObjectProperties}) {
|
||||||
{object.name}
|
{object.name}
|
||||||
</ItemHeading>
|
</ItemHeading>
|
||||||
<div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div>
|
<div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div>
|
||||||
<FeedAttachment object={object} layout={null} />
|
<FeedAttachment layout={null} object={object} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function FeedLayoutContent({object}: {object: ObjectProperties}) {
|
function FeedLayoutContent({object}: {object: ObjectProperties}) {
|
||||||
if (object.type === 'Article') {
|
if (object.type === 'Article') {
|
||||||
return <FeedLayoutArticleContent object={object} />
|
return <FeedLayoutArticleContent object={object} />;
|
||||||
}
|
}
|
||||||
if (object.type === 'Note') {
|
if (object.type === 'Note') {
|
||||||
return <FeedLayoutNoteContent object={object} />
|
return <FeedLayoutNoteContent object={object} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,7 +443,7 @@ const FeedLayout = ({actor, object, type, comments = [], onClick = noop, onComme
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
const ModalLayout = ({actor, object, type, comments = [], onClick = noop, onCommentClick, author}: LayoutProps) => {
|
const ModalLayout = ({actor, object, type, comments = [], onClick = noop, onCommentClick, author}: LayoutProps) => {
|
||||||
const onLikeClick = () => {};
|
const onLikeClick = () => {};
|
||||||
|
@ -493,7 +471,7 @@ const ModalLayout = ({actor, object, type, comments = [], onClick = noop, onComm
|
||||||
<div className='flex flex-col'>
|
<div className='flex flex-col'>
|
||||||
{object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>}
|
{object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>}
|
||||||
<div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.7rem] text-grey-900'></div>
|
<div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.7rem] text-grey-900'></div>
|
||||||
<FeedAttachment object={object} layout="modal"/>
|
<FeedAttachment layout="modal" object={object}/>
|
||||||
<div className='space-between mt-5 flex'>
|
<div className='space-between mt-5 flex'>
|
||||||
<FeedItemStats
|
<FeedItemStats
|
||||||
commentCount={comments.length}
|
commentCount={comments.length}
|
||||||
|
@ -539,7 +517,7 @@ const ReplyLayout = ({actor, object, type, comments = [], onClick = noop, onComm
|
||||||
<div className='flex flex-col'>
|
<div className='flex flex-col'>
|
||||||
{object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>}
|
{object.name && <Heading className='mb-1 leading-tight' level={4} data-test-activity-heading>{object.name}</Heading>}
|
||||||
<div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div>
|
<div dangerouslySetInnerHTML={({__html: object.content})} className='ap-note-content text-pretty text-[1.5rem] text-grey-900'></div>
|
||||||
<FeedAttachment object={object} layout={null}/>
|
<FeedAttachment layout={null} object={object}/>
|
||||||
<div className='space-between mt-5 flex'>
|
<div className='space-between mt-5 flex'>
|
||||||
<FeedItemStats
|
<FeedItemStats
|
||||||
commentCount={comments.length}
|
commentCount={comments.length}
|
||||||
|
@ -598,14 +576,13 @@ const InboxLayout = ({object, comments = [], onClick = noop, onCommentClick, aut
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comments = [], last, onClick = noop, onCommentClick = noop}) => {
|
const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comments = [], last, onClick = noop, onCommentClick = noop}) => {
|
||||||
if (!object) {
|
if (!object) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let author = actor;
|
let author = actor;
|
||||||
if (type === 'Announce' && object.type === 'Note') {
|
if (type === 'Announce' && object.type === 'Note') {
|
||||||
author = typeof object.attributedTo === 'object' ? object.attributedTo as ActorProperties : actor;
|
author = typeof object.attributedTo === 'object' ? object.attributedTo as ActorProperties : actor;
|
||||||
|
@ -614,44 +591,44 @@ const FeedItem: React.FC<FeedItemProps> = ({actor, object, layout, type, comment
|
||||||
if (layout === 'feed') {
|
if (layout === 'feed') {
|
||||||
return <FeedLayout
|
return <FeedLayout
|
||||||
actor={actor}
|
actor={actor}
|
||||||
|
author={author}
|
||||||
|
comments={comments}
|
||||||
object={object}
|
object={object}
|
||||||
type={type}
|
type={type}
|
||||||
comments={comments}
|
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onCommentClick={onCommentClick}
|
onCommentClick={onCommentClick}
|
||||||
author={author}
|
/>;
|
||||||
/>
|
|
||||||
} else if (layout === 'modal') {
|
} else if (layout === 'modal') {
|
||||||
return <ModalLayout
|
return <ModalLayout
|
||||||
actor={actor}
|
actor={actor}
|
||||||
|
author={author}
|
||||||
|
comments={comments}
|
||||||
object={object}
|
object={object}
|
||||||
type={type}
|
type={type}
|
||||||
comments={comments}
|
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onCommentClick={onCommentClick}
|
onCommentClick={onCommentClick}
|
||||||
author={author}
|
/>;
|
||||||
/>
|
|
||||||
} else if (layout === 'reply') {
|
} else if (layout === 'reply') {
|
||||||
return <ReplyLayout
|
return <ReplyLayout
|
||||||
actor={actor}
|
actor={actor}
|
||||||
|
author={author}
|
||||||
|
comments={comments}
|
||||||
|
last={last}
|
||||||
object={object}
|
object={object}
|
||||||
type={type}
|
type={type}
|
||||||
comments={comments}
|
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onCommentClick={onCommentClick}
|
onCommentClick={onCommentClick}
|
||||||
author={author}
|
/>;
|
||||||
last={last}
|
|
||||||
/>
|
|
||||||
} else if (layout === 'inbox') {
|
} else if (layout === 'inbox') {
|
||||||
return <InboxLayout
|
return <InboxLayout
|
||||||
actor={actor}
|
actor={actor}
|
||||||
|
author={author}
|
||||||
|
comments={comments}
|
||||||
object={object}
|
object={object}
|
||||||
type={type}
|
type={type}
|
||||||
comments={comments}
|
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onCommentClick={onCommentClick}
|
onCommentClick={onCommentClick}
|
||||||
author={author}
|
/>;
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (<></>);
|
return (<></>);
|
||||||
|
|
Loading…
Reference in a new issue