Skip to content

Commit

Permalink
Fixed title
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed May 18, 2021
1 parent e78ddb1 commit 9a2fcf0
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 17 deletions.
4 changes: 4 additions & 0 deletions bin/cli.js
Expand Up @@ -34,6 +34,10 @@ const argv = yargs(hideBin(process.argv))
type: 'boolean',
default: true
})
.option('title', {
describe: 'Title',
type: 'string'
})
.option('config', {
describe: 'Config file',
type: 'string'
Expand Down
17 changes: 12 additions & 5 deletions docs/CHANGELOG.html
Expand Up @@ -7,15 +7,15 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<title>Changelog - Docium Documentation Generator</title>
<!-- HEAD -->
<link href='assets/css/common.css' rel='stylesheet'/>
<link href='assets/css/main.css' rel='stylesheet'/>
<link href='assets/css/sidebar.css' rel='stylesheet'/>
<link href='assets/css/content.css' rel='stylesheet'/>
<link href='assets/css/style.css' rel='stylesheet'/>
<link href='assets/css/variables.css' rel='stylesheet'/>
<link href='node_modules/prismjs/themes/prism-tomorrow.css' rel='stylesheet'/>
<link href='assets/css/sidebar.css' rel='stylesheet'/>
<link href='assets/css/style.css' rel='stylesheet'/>
<link rel='icon' type='image/png' href='assets/icons/icon.png'/>
</head>
<body>
Expand Down Expand Up @@ -46,11 +46,18 @@
<article class="markdown-section" id="main">
<h3 id="changelog">Changelog</h3>
<p>All notable changes to this project will be documented in this file. Dates are displayed in UTC.</p>
<h4 id="104"><a title='null' href='https://github.com/xdan/docium/compare/1.0.3...1.0.4'>1.0.4</a></h4>
<h4 id="104"><a title='null' href='https://github.com/xdan/docium/compare/1.0.4...1.0.4'>1.0.4</a></h4>
<ul>
<li>Added sidebar <a title='null' href='https://github.com/xdan/docium/commit/6e4aa5baae41551d2ea28f68df3975e0343f37de'><code>6e4aa5b</code></a></li>
</ul>
<h4 id="104-1"><a title='null' href='https://github.com/xdan/docium/compare/1.0.3...1.0.4'>1.0.4</a></h4>
<blockquote>
<p>18 May 2021</p>
</blockquote>
<ul>
<li>Change directory name <a title='null' href='https://github.com/xdan/docium/commit/fcf91ba2cf3c20c61d77a3c6257ebe411e0c101b'><code>fcf91ba</code></a></li>
<li>Added .nojekyll file <a title='null' href='https://github.com/xdan/docium/commit/2e5776989cc3235f5ae8139e945f76a63d4feb02'><code>2e57769</code></a></li>
<li>Fixed demo link <a title='null' href='https://github.com/xdan/docium/commit/6d993f98e532ea7ad7da6bc08c11c8abbef753f2'><code>6d993f9</code></a></li>
<li>New version 1.0.4. Read more <a title='undefined' href='https://github.com/xdan/docium/blob/master/CHANGELOG.md'>https://github.com/xdan/docium/blob/master/CHANGELOG.md</a> <a title='null' href='https://github.com/xdan/docium/commit/51a43b4ca310452f39c1946dbf13096a0cd04314'><code>51a43b4</code></a></li>
</ul>
<h4 id="103"><a title='null' href='https://github.com/xdan/docium/compare/1.0.2...1.0.3'>1.0.3</a></h4>
<blockquote>
Expand Down
6 changes: 3 additions & 3 deletions docs/documentation/options.html
Expand Up @@ -7,15 +7,15 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<title>--config [ ] <code>(default: &quot;./docium.js&quot; || &quot;./docium.json&quot; || &quot;./.docium&quot;)</code> - Options - Docium Documentation Generator</title>
<!-- HEAD -->
<link href='../assets/css/common.css' rel='stylesheet'/>
<link href='../assets/css/main.css' rel='stylesheet'/>
<link href='../assets/css/sidebar.css' rel='stylesheet'/>
<link href='../assets/css/content.css' rel='stylesheet'/>
<link href='../assets/css/style.css' rel='stylesheet'/>
<link href='../assets/css/variables.css' rel='stylesheet'/>
<link href='../node_modules/prismjs/themes/prism-tomorrow.css' rel='stylesheet'/>
<link href='../assets/css/sidebar.css' rel='stylesheet'/>
<link href='../assets/css/style.css' rel='stylesheet'/>
<link rel='icon' type='image/png' href='../assets/icons/icon.png'/>
</head>
<body>
Expand Down
6 changes: 3 additions & 3 deletions docs/documentation/template.html
Expand Up @@ -7,15 +7,15 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<title>Sidebar - New template - Docium Documentation Generator</title>
<!-- HEAD -->
<link href='../assets/css/common.css' rel='stylesheet'/>
<link href='../assets/css/main.css' rel='stylesheet'/>
<link href='../assets/css/sidebar.css' rel='stylesheet'/>
<link href='../assets/css/content.css' rel='stylesheet'/>
<link href='../assets/css/style.css' rel='stylesheet'/>
<link href='../assets/css/variables.css' rel='stylesheet'/>
<link href='../node_modules/prismjs/themes/prism-tomorrow.css' rel='stylesheet'/>
<link href='../assets/css/sidebar.css' rel='stylesheet'/>
<link href='../assets/css/style.css' rel='stylesheet'/>
<link rel='icon' type='image/png' href='../assets/icons/icon.png'/>
</head>
<body>
Expand Down
6 changes: 3 additions & 3 deletions docs/documentation/themes.html
Expand Up @@ -7,15 +7,15 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<title>Themes - Docium Documentation Generator</title>
<!-- HEAD -->
<link href='../assets/css/common.css' rel='stylesheet'/>
<link href='../assets/css/main.css' rel='stylesheet'/>
<link href='../assets/css/sidebar.css' rel='stylesheet'/>
<link href='../assets/css/content.css' rel='stylesheet'/>
<link href='../assets/css/style.css' rel='stylesheet'/>
<link href='../assets/css/variables.css' rel='stylesheet'/>
<link href='../node_modules/prismjs/themes/prism-tomorrow.css' rel='stylesheet'/>
<link href='../assets/css/sidebar.css' rel='stylesheet'/>
<link href='../assets/css/style.css' rel='stylesheet'/>
<link rel='icon' type='image/png' href='../assets/icons/icon.png'/>
</head>
<body>
Expand Down
6 changes: 3 additions & 3 deletions docs/index.html
Expand Up @@ -7,15 +7,15 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<title>Get started - Docium - Docium Documentation Generator</title>
<!-- HEAD -->
<link href='assets/css/common.css' rel='stylesheet'/>
<link href='assets/css/main.css' rel='stylesheet'/>
<link href='assets/css/sidebar.css' rel='stylesheet'/>
<link href='assets/css/content.css' rel='stylesheet'/>
<link href='assets/css/style.css' rel='stylesheet'/>
<link href='assets/css/variables.css' rel='stylesheet'/>
<link href='node_modules/prismjs/themes/prism-tomorrow.css' rel='stylesheet'/>
<link href='assets/css/sidebar.css' rel='stylesheet'/>
<link href='assets/css/style.css' rel='stylesheet'/>
<link rel='icon' type='image/png' href='assets/icons/icon.png'/>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions src/default.config.js
Expand Up @@ -4,6 +4,7 @@
* Copyright (c) 2013-2021 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
module.exports = {
title: 'Docium Documentation Generator',
theme: 'light',
template: 'default',
debug: false,
Expand Down
13 changes: 13 additions & 0 deletions src/modules/template.js
Expand Up @@ -216,9 +216,22 @@ class Template {

const html = this.events.emit('postHTML', content) || content;

const title = [this.options.title];

for (let i = 1; i <= 3; i += 1) {
if (html.includes('<h' + i)) {
const [, subtitle] = RegExp(`<h${i}[^>]*>(.*)</h${i}>`).exec(html);
title.unshift(subtitle);
}
}

return fs.writeFile(
filePath,
this.tpl
.replace(
/<title>.*<\/title>/,
`<title>${title.join(' - ')}</title>`
)
.replace('<!-- SIDEBAR -->', await this.getSideBar(filePath))
.replace(
'<!-- STYLES -->',
Expand Down
2 changes: 2 additions & 0 deletions types/options.d.ts
Expand Up @@ -5,6 +5,8 @@
*/

export interface IOptions {
title: string;

theme: 'dark' | 'light';

debug: boolean;
Expand Down

0 comments on commit 9a2fcf0

Please sign in to comment.