Skip to content
← Public packages

@kentcdodds/linkedin

Headless helpers for LinkedIn identity, requests, and guarded posting using the saved linkedin OAuth integration.

src/create-article-post.ts

27 lines · 1.2 KB · TypeScript
import { createArticlePost } from './client.ts'
import { parseCreateArticlePostInput } from './create-media-post-input.ts'

/**
 * Create or dry-run a personal-profile LinkedIn article link post.
 * Maps text/url/thumbnail aliases; rejects unknown keys.
 * @param params.url - Article URL to share (aliases: link, articleUrl, href).
 * @param params.title - Explicit link-card title; LinkedIn does not scrape Open Graph metadata.
 * @param params.description - Explicit link-card description.
 * @param params.thumbnailUrl - HTTPS image fetched and uploaded through LinkedIn's Images API.
 * @returns Dry-run preview or published post metadata when `confirm: true`.
 * @example
 * import createArticlePost from 'kody:@kentcdodds/linkedin/create-article-post'
 * const result = await createArticlePost({
 *   text: 'Read this',
 *   url: 'https://example.com',
 *   title: 'Example article',
 *   description: 'A useful article.',
 *   thumbnailUrl: 'https://example.com/thumbnail.jpg',
 *   dryRun: true,
 * })
 * // => { dryRun: true, body: { ... } }
 */
export default async function createArticlePostEntrypoint(params: Record<string, unknown> = {}) {
	const input = parseCreateArticlePostInput(params)
	return createArticlePost(input)
}