tangled
alpha
login
or
join now
gracekind.net
/
tangled-pages
67
fork
atom
Static site hosting via tangled
67
fork
atom
overview
issues
pulls
pipelines
Update for new xrpc API
Grace Kind
5 months ago
55cc4088
a994b784
+15
-8
2 changed files
expand all
collapse all
unified
split
src
knot-client.js
pages-service.js
+13
-6
src/knot-client.js
···
9
}
10
11
async getBlob(filename) {
12
-
const url = `https://${this.domain}/${this.ownerDid}/${
13
-
this.repoName
14
-
}/blob/${this.branch}/${trimLeadingSlash(filename)}`;
0
0
0
15
console.log(`[KNOT CLIENT]: GET ${url}`);
16
const res = await fetch(url);
17
return await res.json();
18
}
19
20
async getRaw(filename) {
21
-
const url = `https://${this.domain}/${this.ownerDid}/${this.repoName}/raw/${
22
-
this.branch
23
-
}/${trimLeadingSlash(filename)}`;
0
0
0
0
24
console.log(`[KNOT CLIENT]: GET ${url}`);
25
const res = await fetch(url, {
26
responseType: "arraybuffer",
···
9
}
10
11
async getBlob(filename) {
12
+
const params = new URLSearchParams({
13
+
repo: `${this.ownerDid}/${this.repoName}`,
14
+
path: trimLeadingSlash(filename),
15
+
ref: this.branch,
16
+
});
17
+
const url = `https://${this.domain}/xrpc/sh.tangled.repo.blob?${params}`;
18
console.log(`[KNOT CLIENT]: GET ${url}`);
19
const res = await fetch(url);
20
return await res.json();
21
}
22
23
async getRaw(filename) {
24
+
const params = new URLSearchParams({
25
+
repo: `${this.ownerDid}/${this.repoName}`,
26
+
path: trimLeadingSlash(filename),
27
+
ref: this.branch,
28
+
raw: "true",
29
+
});
30
+
const url = `https://${this.domain}/xrpc/sh.tangled.repo.blob?${params}`;
31
console.log(`[KNOT CLIENT]: GET ${url}`);
32
const res = await fetch(url, {
33
responseType: "arraybuffer",
+2
-2
src/pages-service.js
···
67
}
68
let content = null;
69
const blob = await this.client.getBlob(filename);
70
-
if (blob.is_binary) {
71
content = await this.client.getRaw(filename);
72
} else {
73
-
content = blob.contents;
74
}
75
if (this.fileCache && content) {
76
const contentSize = Buffer.isBuffer(content)
···
67
}
68
let content = null;
69
const blob = await this.client.getBlob(filename);
70
+
if (blob.isBinary) {
71
content = await this.client.getRaw(filename);
72
} else {
73
+
content = blob.content;
74
}
75
if (this.fileCache && content) {
76
const contentSize = Buffer.isBuffer(content)