Skip to content

Commit

Permalink
Compress fragment files
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed May 27, 2022
1 parent d7b0b41 commit d8e070d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pagefind/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl PagefindIndexes {
write(
outdir.join(format!("fragment/{}.pf_fragment", hash)),
vec![fragment.as_bytes()],
Compress::None,
Compress::GZ,
)
}));

Expand Down
6 changes: 4 additions & 2 deletions pagefind/src/output/stubs/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ class Pagefind {
}

async _loadFragment(hash) {
let fragment = await fetch(`${this.base_path}fragment/${hash}.pf_fragment`);
return await fragment.json();
let compressed_fragment = await fetch(`${this.base_path}fragment/${hash}.pf_fragment`);
compressed_fragment = await compressed_fragment.arrayBuffer();
let fragment = gunzip(new Uint8Array(compressed_fragment));
return JSON.parse(new TextDecoder().decode(fragment));
}

// TODO: Due for a rework (chunking + compression)
Expand Down

0 comments on commit d8e070d

Please sign in to comment.