Don’t do what you should do, do you want.

Progress of xLog SDK

Why do we need xLog SDK?#

Although I am very satisfied with the overall experience of xLog, I have to say that compared to static generated sites like Hexo and VitePress, its access speed is still 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 how the pages are rendered, 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 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 client.site.getInfo
    1. Get site statistics client.site.getStat
  2. Get blog information
    1. Get all blog posts client.post.getAll
    2. Get blog posts with pagination client.post.getMany
    3. Get a single blog post client.post.get or client.post.getBySlug
    4. Create a blog post client.post.put
    5. Update a blog post client.post.update
  3. Get comment information, 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 the 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 access 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 posts 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 prospects#

Regarding the future of 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 xLog server, transfer the project to the Crossbell organization, or even replace the current implementation of xLog server.
  3. Provide server APIs for the SDK, so that we can interact without using the SDK.

Regarding the idea of integrating xLog with the SDK:

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

I believe that the emergence of xLog SDK can make xLog more in line with the concept of decentralization, allowing more and 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.