Simplify the collaborative creation of a new post in a thread

I think it’s perfectly fine. This only needs to send two ajax requests, one to get the original text, and one to process the content and post it as a post.

Wait a minute, I’ll give a critical part of the code

const post_id = 1327039; // You should do some operations before to get the desired post id

$.ajax(`/posts/${post_id}/raw.json`).then(res => {
  const [text, title, raw] = res.match(/\s*#\s+([^\n]+)([\s\S]*)/);
  $.ajax("/posts.json", {
    type: "POST",
    data: {
      raw,
      title,
      category: YOUR_CATEGORY_ID,
    },
  });
});

Building a good-looking and easy-to-use front end should be the most difficult part of this theme component

2 Likes