Skip to content

Commit

Permalink
feat: add the option to set the document title (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjdonkers authored Sep 23, 2021
1 parent 066e066 commit 519fbc9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Options:
--basedir ................ Base directory to be served by the file server
--stylesheet ............. Path to a local or remote stylesheet (can be passed multiple times)
--css .................... String of styles
--document-title ......... Name of the HTML Document.
--body-class ............. Classes to be added to the body tag (can be passed multiple times)
--page-media-type ........ Media type to emulate the page with (default: screen)
--highlight-style ........ Style to be used by highlight.js (default: github)
Expand Down Expand Up @@ -149,6 +150,7 @@ pdf_options:
}
</style>
<section>
<span class="title"></span>
<span class="date"></span>
</section>
footerTemplate: |-
Expand Down Expand Up @@ -183,6 +185,7 @@ For default and advanced options see the following links. The default highlight.
| `--basedir` | `path/to/folder` |
| `--stylesheet` | `path/to/style.css`, `https://example.org/stylesheet.css` |
| `--css` | `body { color: tomato; }` |
| `--document-title` | `Read me` |
| `--body-class` | `markdown-body` |
| `--page-media-type` | `print` |
| `--highlight-style` | `monokai`, `solarized-light` |
Expand Down
1 change: 1 addition & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const cliFlags = arg({
'--watch-options': String,
'--stylesheet': [String],
'--css': String,
'--document-title': String,
'--body-class': [String],
'--page-media-type': String,
'--highlight-style': String,
Expand Down
6 changes: 6 additions & 0 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const defaultConfig: Config = {
stylesheet: [resolve(__dirname, '..', '..', 'markdown.css')],
script: [],
css: '',
document_title: '',
body_class: [],
page_media_type: 'screen',
highlight_style: 'github',
Expand Down Expand Up @@ -78,6 +79,11 @@ interface BasicConfig {
*/
script: FrameAddScriptTagOptions[];

/**
* Name of the HTML Document.
*/
document_title: string;

/**
* List of classes for the body tag.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/lib/get-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getMarked } from './get-marked-with-highlighter';
*/
export const getHtml = (md: string, config: Config) => `<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head>
<head><title>${config.document_title}</title><meta charset="utf-8"></head>
<body class="${config.body_class.join(' ')}">
${getMarked(config.marked_options)(md)}
</body>
Expand Down
1 change: 1 addition & 0 deletions src/lib/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const helpText = `
--basedir ${chalk.dim('................')} Base directory to be served by the file server
--stylesheet ${chalk.dim('.............')} Path to a local or remote stylesheet (can be passed multiple times)
--css ${chalk.dim('....................')} String of styles
--document-title ${chalk.dim('.........')} Name of the HTML Document.
--body-class ${chalk.dim('.............')} Classes to be added to the body tag (can be passed multiple times)
--page-media-type ${chalk.dim('........')} Media type to emulate the page with (default: screen)
--highlight-style ${chalk.dim('........')} Style to be used by highlight.js (default: github)
Expand Down

0 comments on commit 519fbc9

Please sign in to comment.