This commit is contained in:
Morten Olsen
2023-03-26 22:15:07 +02:00
commit 9b1a067d56
80 changed files with 7889 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import { Asset, Bundler } from "../../bundler";
import { Observable } from "../../observable";
import { createEjs } from "../ejs";
import { latexToPdf } from "./utils";
type LatexOptions = {
path: string;
bundler: Bundler;
template: ReturnType<typeof createEjs>;
data: Observable<any>;
};
const createLatex = ({ template, data, path, bundler }: LatexOptions) => {
const pdf = Observable.combine({
template,
data,
})
.pipe(async ({ template, data }) => template(data))
.pipe(async (latex) => {
const pdf = await latexToPdf(latex);
const asset: Asset = {
content: pdf,
};
return asset;
});
return bundler.register(`${path}.pdf`, pdf);
};
export { createLatex };