# 2022-10-11 (December 13, 2022)

<font style="color:rgb(51, 65, 85);">今天发现了对我来说博客最佳的解决方案——</font>[语雀API](https://www.yuque.com/yuque/developer)

<img src="https://picgo.cdn.muspimerol.site/Snipaste_2022-12-11_21-43-31.png" width="1589" title="" crop="0,0,1,1" id="WTAQy" class="ne-image">

[访问频率限制](https://www.yuque.com/yuque/developer/api#5b3a1535)<font style="color:rgb(51, 65, 85);">大概相当于</font>

+ <font style="color:rgb(51, 65, 85);">匿名访问（相当于不登录浏览）约</font>**每分钟3次**
+ <font style="color:rgb(51, 65, 85);">登录访问（主要是本地编辑同步）约</font>**每秒1次**

### 双向同步
+ <font style="color:rgb(51, 65, 85);">可以从云端</font>[get到](https://www.yuque.com/yuque/developer/doc#684fb2c5)<font style="color:rgb(51, 65, 85);">的东西：</font>[DocDetailSerializer](https://www.yuque.com/yuque/developer/docdetailserializer)
    - <font style="color:rgb(51, 65, 85);">body字段：正文的markdown格式</font>
    - <font style="color:rgb(51, 65, 85);">body_html字段：相当于导出的html（不含代码高亮）</font>
    - <font style="color:rgb(51, 65, 85);">body_lake字段：语雀lake格式</font>
+ <font style="color:rgb(51, 65, 85);">只能单向同步：在语雀端编辑的文档会被转化成lake格式</font>

[更新文档](https://www.yuque.com/yuque/developer/doc#c2e9ee2a)<font style="color:rgb(51, 65, 85);">的时候：</font>

_**如果在页面编辑过文档，那这时文档会转成 lake 格式，如果再用 markdown 无法进行更新，这是需要添加 **__**_force_asl = 1**__** 来确保内容的正确转换。**_

---

<font style="color:rgb(51, 65, 85);">总之最后可以做单向的同步，从云端不停地拉到本地（每秒能拉一次</font><font style="color:rgb(51, 65, 85);">😂</font><font style="color:rgb(51, 65, 85);">）</font>

<font style="color:rgb(51, 65, 85);">然后博客是从Svelte前端访问（由于语雀的授权与鉴权机制，token天生地带有授权项而且很方便修改，我觉得甚至其实可以把token直接放在 </font>**page.js**<font style="color:rgb(51, 65, 85);"> 中）</font>

<font style="color:rgb(51, 65, 85);">我觉得还可以加一个在 </font>**xindex**<font style="color:rgb(51, 65, 85);"> 中实现了的缓存（在用户端的SPA页面内容缓存和在服务端的get文档内容的TTL缓存）</font>