Static site hosting via tangled

Update for new xrpc API

Changed files
+15 -8
src
+13 -6
src/knot-client.js
···
}
async getBlob(filename) {
-
const url = `https://${this.domain}/${this.ownerDid}/${
-
this.repoName
-
}/blob/${this.branch}/${trimLeadingSlash(filename)}`;
+
const params = new URLSearchParams({
+
repo: `${this.ownerDid}/${this.repoName}`,
+
path: trimLeadingSlash(filename),
+
ref: this.branch,
+
});
+
const url = `https://${this.domain}/xrpc/sh.tangled.repo.blob?${params}`;
console.log(`[KNOT CLIENT]: GET ${url}`);
const res = await fetch(url);
return await res.json();
}
async getRaw(filename) {
-
const url = `https://${this.domain}/${this.ownerDid}/${this.repoName}/raw/${
-
this.branch
-
}/${trimLeadingSlash(filename)}`;
+
const params = new URLSearchParams({
+
repo: `${this.ownerDid}/${this.repoName}`,
+
path: trimLeadingSlash(filename),
+
ref: this.branch,
+
raw: "true",
+
});
+
const url = `https://${this.domain}/xrpc/sh.tangled.repo.blob?${params}`;
console.log(`[KNOT CLIENT]: GET ${url}`);
const res = await fetch(url, {
responseType: "arraybuffer",
+2 -2
src/pages-service.js
···
}
let content = null;
const blob = await this.client.getBlob(filename);
-
if (blob.is_binary) {
+
if (blob.isBinary) {
content = await this.client.getRaw(filename);
} else {
-
content = blob.contents;
+
content = blob.content;
}
if (this.fileCache && content) {
const contentSize = Buffer.isBuffer(content)