Edits history of script submission #8949 for ' Create Post (ghostcms)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import GhostAdminAPI from '@tryghost/admin-api'
    
    type Ghostcms = {
    	apiKey: string
    	apiUrl: string
    }
    
    export async function main(
    	resource: Ghostcms,
    	payload: {
    		title: string
    		slug?: string
    		status: 'draft' | 'published' | 'scheduled'
    		featured?: boolean
    		custom_excerpt?: string
    		tags?: {
    			name: string
    		}[]
    		authors?: {
    			id: string
    		}[]
    	}
    ) {
    	const apiClient = new GhostAdminAPI({
    		url: resource.apiUrl,
    		version: 'v5.87',
    		key: resource.apiKey
    	})
    
    	const response = await apiClient.posts.add(payload)
    
    	return response
    }
    

    Submitted by hugo697 652 days ago