Skip to content

Commit

Permalink
Merge pull request #9 from brunobmello25/master
Browse files Browse the repository at this point in the history
fix: remove article from wrapping content
  • Loading branch information
asnunes authored Mar 1, 2021
2 parents 6b4add0 + 8630467 commit cb658c1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 30 deletions.
28 changes: 12 additions & 16 deletions __tests__/mocks/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,13 @@ const HEADER = `\
</header>
`;

const ARTICLE_CONTENT = `\
<article class="page sans">
${HEADER}
<p>Hello World</p>
</article>
const CONTENT_WITH_HEADER = `\
${HEADER}
<p>Hello World</p>
`;

const ARTICLE_CONTENT_WITHOUT_HEADER = `\
<article class="page sans">
<p>Hello World</p>
</article>
const CONTENT_WITHOUT_HEADER = `\
<p>Hello World</p>
`;

export const FULL_DOCUMENT = `
Expand All @@ -289,7 +285,7 @@ export const FULL_DOCUMENT = `
<link href="https://unpkg.com/prismjs@1.22.0/themes/prism.css" rel="stylesheet">
</head>
<body>
${ARTICLE_CONTENT}
${CONTENT_WITH_HEADER}
<script src="https://unpkg.com/prismjs@1.22.0/components/prism-core.min.js"></script>
<script src="https://unpkg.com/prismjs@1.22.0/plugins/autoloader/prism-autoloader.min.js"></script>
<script>
Expand All @@ -316,7 +312,7 @@ export const DOCUMENT_WITHOUT_TITLE = `
<link href="https://unpkg.com/prismjs@1.22.0/themes/prism.css" rel="stylesheet">
</head>
<body>
${ARTICLE_CONTENT}
${CONTENT_WITH_HEADER}
<script src="https://unpkg.com/prismjs@1.22.0/components/prism-core.min.js"></script>
<script src="https://unpkg.com/prismjs@1.22.0/plugins/autoloader/prism-autoloader.min.js"></script>
<script>
Expand All @@ -343,7 +339,7 @@ export const DOCUMENT_WITHOUT_CSS = `
<link href="https://unpkg.com/prismjs@1.22.0/themes/prism.css" rel="stylesheet">
</head>
<body>
${ARTICLE_CONTENT}
${CONTENT_WITH_HEADER}
<script src="https://unpkg.com/prismjs@1.22.0/components/prism-core.min.js"></script>
<script src="https://unpkg.com/prismjs@1.22.0/plugins/autoloader/prism-autoloader.min.js"></script>
<script>
Expand All @@ -369,7 +365,7 @@ export const DOCUMENT_METADATA = `
<link href="https://unpkg.com/prismjs@1.22.0/themes/prism.css" rel="stylesheet">
</head>
<body>
${ARTICLE_CONTENT}
${CONTENT_WITH_HEADER}
<script src="https://unpkg.com/prismjs@1.22.0/components/prism-core.min.js"></script>
<script src="https://unpkg.com/prismjs@1.22.0/plugins/autoloader/prism-autoloader.min.js"></script>
<script>
Expand All @@ -396,7 +392,7 @@ export const DOCUMENT_WITHOUT_SCRIPTS = `
<title>Simple Page Test</title>
</head>
<body>
${ARTICLE_CONTENT}
${CONTENT_WITH_HEADER}
</body>
</html>
`;
Expand All @@ -412,7 +408,7 @@ export const FULL_DOCUMENT_WITHOUT_HEADER_IN_BODY = `
<link href="https://unpkg.com/prismjs@1.22.0/themes/prism.css" rel="stylesheet">
</head>
<body>
${ARTICLE_CONTENT_WITHOUT_HEADER}
${CONTENT_WITHOUT_HEADER}
<script src="https://unpkg.com/prismjs@1.22.0/components/prism-core.min.js"></script>
<script src="https://unpkg.com/prismjs@1.22.0/plugins/autoloader/prism-autoloader.min.js"></script>
<script>
Expand All @@ -429,7 +425,7 @@ export const FULL_DOCUMENT_WITHOUT_HEADER_IN_BODY = `
</html>
`;

export const BODY_ONLY = ARTICLE_CONTENT_WITHOUT_HEADER;
export const BODY_ONLY = CONTENT_WITHOUT_HEADER;

export const HEADER_WITH_TITLE_ONLY = `\
<header>
Expand Down
6 changes: 2 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-page-to-html",
"version": "1.0.3",
"version": "1.1.0",
"description": "It converts public notion pages to html from url",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -44,6 +44,5 @@
"prettier": "^2.1.2",
"ts-jest": "^26.4.3",
"typescript": "^4.0.5"
},
"dependencies": {}
}
}
8 changes: 1 addition & 7 deletions src/data/usecases/html-wrapper/options-html-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ export class OptionsHtmlWrapper implements HtmlWrapper {
}

wrapHtml(pageProps: PageProps, html: string): string {
if (this._options.bodyContentOnly)
return `\
<article class="page sans">
${html}
</article>`;
if (this._options.bodyContentOnly) return html;

const title = pageProps.title;

Expand All @@ -26,10 +22,8 @@ ${html}
<html>
${this._headFromTemplate(title)}
<body>
<article class="page sans">
${!this._options.excludeHeaderFromBody ? new HeaderFromTemplate(pageProps).toHeader() : ''}
${html}
</article>
${!this._options.excludeScripts ? SCRIPTS : ''}
</body>
</html>`;
Expand Down

0 comments on commit cb658c1

Please sign in to comment.