Download spectrum/api/queries/thread/metaImage.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 748 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/thread/metaImage.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/queries/thread/metaImage.js
-
curl -L -o metaImage.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/queries/thread/metaImage.js
748 Bytes
| // @flow | |
| import type { GraphQLContext } from '../../'; | |
| import type { DBThread } from 'shared/types'; | |
| import generateImageFromText from '../../utils/generate-thread-meta-image-from-text'; | |
| import { signImageUrl } from 'shared/imgix'; | |
| export default async (thread: DBThread, _: any, ctx: GraphQLContext) => { | |
| const { loaders } = ctx; | |
| const { watercooler, communityId, content } = thread; | |
| const community = await loaders.community.load(communityId); | |
| if (!community) return null; | |
| const imageUrl = generateImageFromText({ | |
| title: watercooler | |
| ? `Chat with the ${community.name} community` | |
| : content.title, | |
| footer: `spectrum.chat/${community.slug}`, | |
| }); | |
| if (!imageUrl) return null; | |
| return signImageUrl(imageUrl); | |
| }; | |