Why Do We Need xLog SDK?#
Although I am very satisfied with the overall experience of xLog, I have to say that its access speed is somewhat slow compared to static generated sites like Hexo and VitePress. Currently, we do not have a simple way to deploy xLog ourselves or use xLog's data to generate static sites.
xLog allows us to easily customize the appearance of the website through CSS, but when it comes to how to render the pages, such customization is limited. In the article How to Elegantly Compile a Markdown Document, diygod introduces how xLog renders Markdown. However, you might be dissatisfied with the code highlighting style 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 user of xLog. If we could control how to render Markdown ourselves, we would have more freedom.
For many people, xLog is not their only platform for blogging, note-taking, or publishing daily updates; some may be accustomed to using VS Code to edit blogs, while others prefer Obsidian. Having an xLog SDK would mean that when integrating with other platforms, community authors would not need to implement the logic of the xLog server themselves. This repetitive work should be unified and solved through the SDK.
Current SDK Features#
I have released version 0.1.0 of sakuin, which you can install via npm:
ni sakuin
Import Client
from sakuin and use it; it is based on crossbell.js
. Generally, you need to pass 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 types of operations:
- Get site information
client.site.getInfo
- Get site statistics
client.site.getStat
- Get site statistics
- Get blog information
- Get all blogs
client.post.getAll
- Paginate to get blogs
client.post.getMany
- Get a single blog
client.post.get
orclient.post.getBySlug
- Create a blog
client.post.put
- Update a blog
client.post.update
- Get all blogs
- Get comment information and send anonymous comments
- Get short and portfolio information
I cannot introduce all the APIs and parameters available to you here; you can learn how to use them through TS 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, and you can compare its access speed with the original xLog. In addition, I have re-implemented the layout and article rendering according to my preferences, giving me complete control and freedom. By integrating the anonymous comment interface provided by xLog, I can easily implement a comment module.
The VS Code xLog plugin allows you to download all blog articles to your local machine, edit or create your blog locally. You can also upload local files or remote link files to IPFS within VS Code.
Some Outlook#
Regarding the future of xLog SDK, I can think of the following points:
- Further improve the APIs needed for third-party interactions with xLog, contact xLog community authors, and provide a unified and convenient development experience for community authors.
- Fully implement the capabilities of the xLog server, transition the project to the Crossbell organization, and even replace the current implementation of the xLog server.
- Provide server APIs for the SDK so that we can interact without going through the SDK.
Ideas for integrating xLog using the SDK include:
- Integrate git commit hooks to automatically create and update blogs.
I believe the emergence of xLog SDK can make xLog more aligned with the concept of decentralization, allowing more people to truly utilize their own data rather than just accessing it through the platform. By the way, this blog was written in VS Code and published using the xLog plugin.