PlantUMLファイルから画像URLを生成するserverless function
2021-09-08 06:53:10 どうやら公式でproxyが提供されていたらしい……
だけどなぜか公式のproxyだとscrapboxのコードブロックを読み込めないらしい
2021-12-18 06:53:23 content-type
が正しくないと弾いているんじゃないか?
なので代わりにこのserverless functionを使う必要が依然としてある
まあ結果オーライということで
書式
https://plantuml-proxy.vercel.app/:img/:url
:url
PlantUMLが書かれたファイルへのURLを渡す
:type
画像の形式
png
か svg
実装したいこと

codeのrefactoring
src/
を作ってそっちにmoduleを移す
jpg
も使えるようにする
example
test2.puml@startuml
hide empty description
[*] -right-> register
[*] -right-> ocount
[*] -right-> operator
[*] -right-> count
[*] -right-> motion
state "operator\ncount" as ocount
register --> ocount
register -right-> operator
ocount -right-> operator
operator -up-> count
operator -right-> motion
count -right-> motion
operator --> [*]
motion --> [*]
@enduml
mechanism.puml@startdot
digraph foo {
label="plantuml-proxyのしくみ";
node [fontsize = 12, shape = box, style=rounded ];
s1 [label="Scrapboxページ"];
s2 [label="plantuml-proxy"];
s3 [label="キャッシュ", shape=oval];
s4 [label="PlantUML WebAPI"];
s1 -> s2 [label="コードブロックでPlantUMLを書く"];
s2 -> s3 [label="レンダリング結果をキャッシュ"];
s2 -> s4 [label="レンダリング"];
{rank = same; s2; s3;}
}
@enddot
実装
vercel + deno
MD5 hashを
ETagに入れてcacheの比較をしている……が、効果があるのかはよくわからん