Nhảy đến nội dung chính

Blog Posts

The Blog post components enable your gateway to promote regular Near Social posts into fully fledged blog posts. In this article you'll learn how to set up the required components so you can define a custom URL to show a clean feed of blog posts.


To set up the Blog post features on your near-discovery gateway:

  1. Add the Blog.Feed and BlogPostPage components
  2. Add near/widget/Blog.Feed and near/widget/BlogPostPage to your configuration
  • Edit your bos-components.ts configuration file:

Blog feed URL

To set a custom URL such as /bosblog for your Blog feed, and define which users will be shown on it, do the following changes on your near-discovery gateway:

  1. Create a folder src/pages/<customURL> for your desired custom path (e.g., /bosblog)
  2. Add this index.tsx file to src/pages/bosblog/:
  1. Edit the contributors list, with the account(s) that you want to showcase on your blog feed:

    const contributors = ['near', 'jacksonthedev.near'];

That's all, your gateway setup is done and you're ready to show your blog feed. Check the next sections if you want to learn more about the blog post content formatting and how to promote social messages into blog posts.


In this code example, only promoted blog posts from users near and jacksonthedev.near will appear in the Blog feed when someone browses the /bosblog URL.

Promoting posts

If you're using near-discovery you're all set, the Promote menu is already available using the v1.Posts.Feed component.

If you're using a different gateway or your own custom feed, and you want to allow users to promote social messages into blog posts, you can integrate this promoteToBlog code snippet:

const { accountId, blockHeight, item } = props;

const promoteToBlog = () => {
if (state.loading) {

if (!context.accountId && props.requestAuthentication) {
} else if (!context.accountId) {

loading: true,

const data = {
index: {
promote: JSON.stringify({
key: context.accountId,
value: {
operation: "add",
type: "blog",
post: item,

Social.set(data, {
onCommit: () => State.update({ loading: false }),
onCancel: () =>
loading: false,

Check the Posts.Menu component for a complete implementation that includes a drop-down menu and a button to promote a blog post.

Blog post formatting

When writing blog posts, you can format the content using standard Markdown syntax. Markdown is an easy-to-read, easy-to-write language for formatting plain text.

The only two special cases that you should keep in mind when writing a blog post are:

  • the blog post's title
  • an optional header image

Header image

To define an image for your blog post, just add a markdown image link at the top of your post:


Blog post title

To set the post's title, define it using a top heading tag:

# This is the title of a demo blog post

If you're new to Markdown, you might want to check this page about basic writing and formatting syntax.

Writing a blog post

Adding a new blog post is simple. To publish a new blog post, you only need to:

  1. Write a regular Near Social message

  2. Repost the message and convert it to a Blog post

    Once the message has been posted, promoting it to a blog post is straight forward. Just click on the repost button, and select the Blog option:

    blog post

  3. That's it, your blog post has been published, and you can find it under the Blog tab in your social profile:

    blog post


You can find the published blog post example in this link.

Was this page helpful?