Progress of xLog SDK

Why do we need the xLog SDK?#

Although I am very satisfied with the overall experience of xLog, I have to say that compared to static site generators like Hexo and VitePress, its loading speed is a bit slow. Currently, we don't have a simple way to deploy xLog ourselves or generate static sites using xLog data.

xLog allows us to easily customize the appearance of our website through CSS, but when it comes to rendering pages, the customization options are limited. In the article "How to Compile a Markdown Document Gracefully" by diygod, he explains how xLog renders Markdown. However, you may not be satisfied with the style of code highlighting or have a need to highlight specific lines. Sometimes, you can meet your requirements by submitting a PR to xLog, but not all requirements are suitable for every xLog user. If we can control how Markdown is rendered ourselves, we will have more freedom.

For many people, xLog is not their only platform for blogging, note-taking, or publishing daily content. Some people are used to using VS Code to edit their blogs, while others prefer Obsidian. With an xLog SDK, when integrating with other platforms, community authors don't need to implement the logic of an xLog server for each person. This repetitive work should be unified through the SDK.

Current functionalities of the SDK#

I have released version 0.1.0 of sakuin, which you can install via npm:

npm install sakuin

Import Client from sakuin and use it, which is based on crossbell.js. Generally, you need to pass the handle to get data for a specific site, which is your xLog subdomain.

import { Client } from "sakuin"

const client = new Client()
const site = await client.site.getInfo(HANDLE)

You can perform the following operations:

  1. Get site information with client.site.getInfo
    1. Get site statistics with client.site.getStat
  2. Get blog information
    1. Get all blog posts with client.post.getAll
    2. Get blog posts in pagination with client.post.getMany
    3. Get a single blog post with client.post.get or client.post.getBySlug
    4. Create a blog post with client.post.put
    5. Update a blog post with client.post.update
  3. Get comment information and send anonymous comments
  4. Get short and portfolio information

I cannot introduce all the available APIs and parameters here, but you can learn how to use them through TypeScript types, and I will also generate documentation later.

What can we do with the SDK?#

sakuin is derived from my blog project, so naturally, I use it to build my own blog. You can compare its loading speed with the original xLog. In addition, I have re-implemented the layout and rendering of articles according to my preferences, giving me complete control and freedom. By integrating with the anonymous comment interface provided by xLog, I can easily implement a comment module.

Screenshot of the comment interface

VS Code xLog plugin, with this plugin, you can download all blog articles to your local machine and edit or create your blog locally.

You can also upload local files or remote linked files to IPFS in VS Code.

Some future prospects#

Regarding the future of the xLog SDK, I can think of the following points:

  1. Further improve the APIs needed for third-party interaction with xLog and contact xLog community authors to provide a unified and convenient development experience for community authors.
  2. Fully implement the capability of an xLog server, transfer the project to the Crossbell organization, or even replace the current implementation of the xLog server.
  3. Provide server APIs for the SDK so that we can interact without using the SDK.

Regarding the idea of integrating xLog using the SDK:

  1. Integrate git commit hooks to automatically create and update blog posts.

I believe the emergence of the xLog SDK can make xLog more in line with the concept of decentralization, allowing more people to truly utilize their own data instead of just accessing it through platforms. BTW, this blog post was written in VS Code and published using the xLog plugin.

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.