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
9
}
10
10
11
11
async getBlob(filename) {
12
12
-
const url = `https://${this.domain}/${this.ownerDid}/${
13
13
-
this.repoName
14
14
-
}/blob/${this.branch}/${trimLeadingSlash(filename)}`;
12
12
+
const params = new URLSearchParams({
13
13
+
repo: `${this.ownerDid}/${this.repoName}`,
14
14
+
path: trimLeadingSlash(filename),
15
15
+
ref: this.branch,
16
16
+
});
17
17
+
const url = `https://${this.domain}/xrpc/sh.tangled.repo.blob?${params}`;
15
18
console.log(`[KNOT CLIENT]: GET ${url}`);
16
19
const res = await fetch(url);
17
20
return await res.json();
18
21
}
19
22
20
23
async getRaw(filename) {
21
21
-
const url = `https://${this.domain}/${this.ownerDid}/${this.repoName}/raw/${
22
22
-
this.branch
23
23
-
}/${trimLeadingSlash(filename)}`;
24
24
+
const params = new URLSearchParams({
25
25
+
repo: `${this.ownerDid}/${this.repoName}`,
26
26
+
path: trimLeadingSlash(filename),
27
27
+
ref: this.branch,
28
28
+
raw: "true",
29
29
+
});
30
30
+
const url = `https://${this.domain}/xrpc/sh.tangled.repo.blob?${params}`;
24
31
console.log(`[KNOT CLIENT]: GET ${url}`);
25
32
const res = await fetch(url, {
26
33
responseType: "arraybuffer",
+2
-2
src/pages-service.js
···
67
67
}
68
68
let content = null;
69
69
const blob = await this.client.getBlob(filename);
70
70
-
if (blob.is_binary) {
70
70
+
if (blob.isBinary) {
71
71
content = await this.client.getRaw(filename);
72
72
} else {
73
73
-
content = blob.contents;
73
73
+
content = blob.content;
74
74
}
75
75
if (this.fileCache && content) {
76
76
const contentSize = Buffer.isBuffer(content)