Skip to content

Commit

Permalink
Adds title handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Titou325 committed Jan 31, 2024
1 parent c2608e2 commit e9e3248
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
15 changes: 3 additions & 12 deletions packages/client-js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export interface PathString {
path: string;
content: string;
}
export interface PathBuffer{
export interface PathBuffer {
path: string;
content: Buffer;
}
Expand All @@ -13,13 +13,7 @@ export interface ExternalLink {
}
export interface DocumentInput {
html: string;
metadata?: {
title?: string;
author?: string;
subject?: string;
keywords?: string[];
date?: string;
};
title?: string;
assets?: PathString[] | PathBuffer[];
//| ExternalLink
}
Expand Down Expand Up @@ -142,12 +136,9 @@ export class Onedoc {
});

if (asset?.content) {

await uploadToSignedUrl(e.signedUrl, e.path, e.token, asset.content);

} else if (e.path == "/index.html") {

let htmlBuilder = new HtmlBuilder("Onedoc");
let htmlBuilder = new HtmlBuilder(document.title);

const styleSheets = document.assets
?.filter((asset) => asset.path.includes(".css"))
Expand Down
12 changes: 7 additions & 5 deletions packages/client-js/src/htmlBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
export class HtmlBuilder {
private title: string = "Onedoc";
private title?: string;
private start: string = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset = "UTF-8">
<meta name="viewport" content="width=device-width">`;
private middle: string = `<title>Onedoc</title>
private middle: string = `
</head>
<body>`;

private end: string = `</body>
</html>`;

private styleSheets: string[];

constructor(title: string) {
constructor(title?: string) {
this.title = title;
}

Expand All @@ -25,6 +23,10 @@ export class HtmlBuilder {
});
}

if (this.title) {
this.start += `<title>${this.title}</title>`;
}

this.middle += react;

return this.start + this.middle + this.end;
Expand Down

0 comments on commit e9e3248

Please sign in to comment.