Software Alternatives & Reviews

How to automatically publish a new post to Dev.to with Next.js and Sanity CMS

Vercel X (Twitter) Medium Hashnode DEV.to
  1. 1
    Vercel is the platform for frontend developers, providing the speed and reliability innovators need to create at the moment of inspiration.
    This will now expose your API as: https://example.com/api/post-to-dev-community. Deploy your code to your respective hosting platform. In this case, I am just using Vercel to do so.

    #Developer Tools #Web Development Tools #App Deployment 518 social mentions

  2. Connect with your friends and other fascinating people. Get in-the-moment updates on the things that interest you. And watch events unfold, in real time, from every angle.
    Writing and publishing a new post on our blog and sharing our knowledge is great. To get a better outreach, we would also like to publish our post on Dev.to, Hashnode, Medium or maybe sharing on Twitter for the visibility. Having to manually copy and paste our content on the respective platforms can be troublesome, even more so if we need to update our content across the different platforms.

    #Social Networks #Social Network #Microblogging 883 social mentions

  3. 3
    Welcome to Medium, a place to read, write, and interact with the stories that matter most to you.
    Pricing:
    • Open Source
    Writing and publishing a new post on our blog and sharing our knowledge is great. To get a better outreach, we would also like to publish our post on Dev.to, Hashnode, Medium or maybe sharing on Twitter for the visibility. Having to manually copy and paste our content on the respective platforms can be troublesome, even more so if we need to update our content across the different platforms.

    #Blogging #Blogging Platform #CMS 2164 social mentions

  4. A friendly and inclusive Q&A network for coders
    Writing and publishing a new post on our blog and sharing our knowledge is great. To get a better outreach, we would also like to publish our post on Dev.to, Hashnode, Medium or maybe sharing on Twitter for the visibility. Having to manually copy and paste our content on the respective platforms can be troublesome, even more so if we need to update our content across the different platforms.

    #Web App #Social Media Tools #Software Engineering 119 social mentions

  5. 5
    Where software engineers connect, build their resumes, and grow.
    Import { NextApiRequest, NextApiResponse } from "next"; Import { HOST_URL } from "lib/config"; Import { sanityClient } from "lib/sanity-server"; Import { postUpdatedQuery } from "lib/queries"; Const handler = async (req: NextApiRequest, res: NextApiResponse) => { const body = await readBody(req); const publishedPost = JSON.parse(body); const { _id: id, content } = publishedPost; const slug = await sanityClient.fetch(postUpdatedQuery, { id }); try { const post = await fetch("https://dev.to/api/articles", { method: "POST", headers: { "Content-Type": "application/json", "api-key": process.env.DEV_TO_API_KEY }, body: JSON.stringify({ article: { ...publishedPost, body_markdown: content, published: true, canonical_url: `${HOST_URL}/blog/${slug}` } }) }).then((res) => res.json()); console.log(post); return res .status(200) .json({ message: `Successfully published on: ${post.url}` }); } catch (err) { return res.status(400).json({ message: err.message }); } }; Export default handler; // Next.js will by default parse the body, which can lead to invalid signatures Export const config = { api: { bodyParser: false } }; Const readBody = async (readable: NextApiRequest) => { const chunks = []; for await (const chunk of readable) { chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk); } return Buffer.concat(chunks).toString("utf-8"); };.

    #CMS #Blogging #Blogging Platform 375 social mentions

Discuss: How to automatically publish a new post to Dev.to with Next.js and Sanity CMS

Log in or Post with