Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/src/preview/preview-static.ts
6433 views
1
/*
2
* preview-static.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*/
6
7
import { join, relative } from "../deno_ral/path.ts";
8
import { resourcePath } from "../core/resources.ts";
9
import { jatsStaticResources } from "./preview-text.ts";
10
11
export const staticResource = async (
12
baseDir: string,
13
file: string,
14
) => {
15
const filename = relative(baseDir, file);
16
const resource = kStaticResources.find((resource) => {
17
return resource.name === filename;
18
});
19
20
if (resource) {
21
const dir = resource.dir ? join("preview", resource.dir) : "preview";
22
const path = resourcePath(join(dir, filename));
23
const contents = await Deno.readFile(path);
24
return {
25
...resource,
26
contents,
27
};
28
}
29
};
30
31
// Static reources provide a list of 'special' resources that we should
32
// satisfy using internal resources
33
const kStaticResources = [
34
...jatsStaticResources(),
35
];
36
37