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 generated sites like Hexo and VitePress, its loading 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 using 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 needs by submitting a PR to xLog, but not all needs 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 daily publishing. 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#
Github Repo not found
The embedded github repo could not be found…
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:
- Get site information with
client.site.getInfo
- Get site statistics with
client.site.getStat
- Get site statistics with
- Get blog information
- Get all blogs with
client.post.getAll
- Get blogs in pagination with
client.post.getMany
- Get a single blog with
client.post.get
orclient.post.getBySlug
- Create a blog with
client.post.put
- Update a blog with
client.post.update
- Get all blogs with
- Get comment information, send anonymous comments
- 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.
Github Repo not found
The embedded github repo could not be found…
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 prospects#
Regarding the future of the xLog SDK, I can think of the following points:
- 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.
- Fully implement the ability of an xLog server, transfer the project to the Crossbell organization, or even replace the current implementation of the xLog server.
- Provide server APIs for the SDK so that we can interact without using the SDK.
Regarding the idea of integrating xLog using the SDK:
- Integrate git commit hooks to automatically create and update blogs.
I believe that the emergence of the 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.