Skip to content

Commit 997f235

Browse files
committed
fix drafts document title
1 parent 16e6fab commit 997f235

File tree

5 files changed

+168
-182
lines changed

5 files changed

+168
-182
lines changed

package.json

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,24 @@
1515
"add-dist": "mkdirp ./lib/jekyll-admin/public",
1616
"remove-dist": "rimraf ./lib/jekyll-admin/public",
1717
"build:html": "babel-node tools/buildHtml.js",
18-
"prebuild":
19-
"npm run clean-dist && npm run build:html && npm run lint && npm test",
18+
"prebuild": "npm run clean-dist && npm run build:html && npm run lint && npm test",
2019
"build": "babel-node tools/build.js",
2120
"test": "jest",
2221
"test:CI": "babel-node tools/testCi.js",
2322
"test:cover": "npm run test -- --coverage ",
24-
"test:cover:CI":
25-
"npm run test:CI -- --coverage && cat ./coverage/lcov.info | node_modules/coveralls/bin/coveralls.js",
23+
"test:cover:CI": "npm run test:CI -- --coverage && cat ./coverage/lcov.info | node_modules/coveralls/bin/coveralls.js",
2624
"test:watch": "npm run test -- --watch",
27-
"open:cover":
28-
"npm run test:cover && open ./coverage/lcov-report/index.html",
25+
"open:cover": "npm run test:cover && open ./coverage/lcov-report/index.html",
2926
"precommit": "lint-staged"
3027
},
3128
"lint-staged": {
32-
"*.js": ["prettier --single-quote --trailing-comma es5 --write"]
29+
"*.js": [
30+
"prettier --single-quote --trailing-comma es5 --write"
31+
]
3332
},
3433
"author": "Mert Kahyaoğlu",
3534
"license": "MIT",
3635
"dependencies": {
37-
"babel-plugin-transform-class-properties": "^6.24.1",
38-
"babel-preset-latest": "^6.24.1",
3936
"brace": "0.9.1",
4037
"classnames": "2.2.5",
4138
"highlight.js": "^9.10.0",
@@ -116,13 +113,22 @@
116113
"\\.(css|scss)$": "identity-obj-proxy",
117114
"^.+\\.(gif|ttf|eot|svg|woff|woff2|ico)$": "<rootDir>/tools/fileMock.js"
118115
},
119-
"roots": ["src"],
120-
"testMatch": ["**/*.spec.js"]
116+
"roots": [
117+
"src"
118+
],
119+
"testMatch": [
120+
"**/*.spec.js"
121+
]
121122
},
122123
"babel": {
123124
"env": {
124125
"development": {
125-
"presets": ["env", "react", "react-hmre", "stage-1"]
126+
"presets": [
127+
"env",
128+
"react",
129+
"react-hmre",
130+
"stage-1"
131+
]
126132
},
127133
"production": {
128134
"presets": [
@@ -147,7 +153,11 @@
147153
]
148154
},
149155
"test": {
150-
"presets": ["env", "react", "stage-1"]
156+
"presets": [
157+
"env",
158+
"react",
159+
"stage-1"
160+
]
151161
}
152162
}
153163
},
@@ -158,7 +168,9 @@
158168
"plugin:import/errors",
159169
"plugin:import/warnings"
160170
],
161-
"plugins": ["react"],
171+
"plugins": [
172+
"react"
173+
],
162174
"parser": "babel-eslint",
163175
"parserOptions": {
164176
"ecmaVersion": 6,
@@ -182,7 +194,10 @@
182194
"no-unused-vars": 0,
183195
"no-debugger": 1,
184196
"no-var": 1,
185-
"semi": [1, "always"],
197+
"semi": [
198+
1,
199+
"always"
200+
],
186201
"no-trailing-spaces": 0,
187202
"eol-last": 0,
188203
"no-underscore-dangle": 0,

src/containers/views/DraftEdit.js

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { connect } from 'react-redux';
44
import { bindActionCreators } from 'redux';
55
import { browserHistory, withRouter } from 'react-router';
66
import _ from 'underscore';
7+
import DocumentTitle from 'react-document-title';
78
import { HotKeys } from 'react-hotkeys';
89
import Button from '../../components/Button';
910
import Splitter from '../../components/Splitter';
@@ -116,52 +117,63 @@ export class DraftEdit extends Component {
116117
collection,
117118
front_matter
118119
);
120+
const document_title = directory
121+
? `${title || name} - ${directory} - Drafts`
122+
: `${title || name} - Drafts`;
119123

120124
return (
121-
<HotKeys handlers={keyboardHandlers} className="single">
122-
{errors.length > 0 && <Errors errors={errors} />}
123-
<div className="content-header">
124-
<Breadcrumbs splat={directory || ''} type="drafts" />
125-
</div>
126-
127-
<div className="content-wrapper">
128-
<div className="content-body">
129-
<InputPath onChange={updatePath} type="drafts" path={name} />
130-
<InputTitle onChange={updateTitle} title={title} ref="title" />
131-
<MarkdownEditor
132-
onChange={updateBody}
133-
onSave={this.handleClickSave}
134-
placeholder="Body"
135-
initialValue={raw_content}
136-
ref="editor"
137-
/>
138-
<Splitter />
139-
<Metadata
140-
fields={{ title, raw_content, path: name, ...metafields }}
141-
/>
125+
<DocumentTitle title={document_title}>
126+
<HotKeys handlers={keyboardHandlers} className="single">
127+
{errors.length > 0 && <Errors errors={errors} />}
128+
<div className="content-header">
129+
<Breadcrumbs splat={directory || ''} type="drafts" />
142130
</div>
143131

144-
<div className="content-side">
145-
<Button
146-
onClick={this.handleClickSave}
147-
type="save"
148-
active={fieldChanged}
149-
triggered={updated}
150-
icon="save"
151-
block
152-
/>
153-
<Button to={http_url} type="view" icon="eye" active={true} block />
154-
<Splitter />
155-
<Button
156-
onClick={() => this.handleClickDelete(name)}
157-
type="delete"
158-
active={true}
159-
icon="trash"
160-
block
161-
/>
132+
<div className="content-wrapper">
133+
<div className="content-body">
134+
<InputPath onChange={updatePath} type="drafts" path={name} />
135+
<InputTitle onChange={updateTitle} title={title} ref="title" />
136+
<MarkdownEditor
137+
onChange={updateBody}
138+
onSave={this.handleClickSave}
139+
placeholder="Body"
140+
initialValue={raw_content}
141+
ref="editor"
142+
/>
143+
<Splitter />
144+
<Metadata
145+
fields={{ title, raw_content, path: name, ...metafields }}
146+
/>
147+
</div>
148+
149+
<div className="content-side">
150+
<Button
151+
onClick={this.handleClickSave}
152+
type="save"
153+
active={fieldChanged}
154+
triggered={updated}
155+
icon="save"
156+
block
157+
/>
158+
<Button
159+
to={http_url}
160+
type="view"
161+
icon="eye"
162+
active={true}
163+
block
164+
/>
165+
<Splitter />
166+
<Button
167+
onClick={() => this.handleClickDelete(name)}
168+
type="delete"
169+
active={true}
170+
icon="trash"
171+
block
172+
/>
173+
</div>
162174
</div>
163-
</div>
164-
</HotKeys>
175+
</HotKeys>
176+
</DocumentTitle>
165177
);
166178
}
167179
}

src/containers/views/DraftNew.js

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { connect } from 'react-redux';
44
import { bindActionCreators } from 'redux';
55
import { browserHistory, withRouter } from 'react-router';
66
import { HotKeys } from 'react-hotkeys';
7+
import DocumentTitle from 'react-document-title';
78
import Splitter from '../../components/Splitter';
89
import Errors from '../../components/Errors';
910
import Breadcrumbs from '../../components/Breadcrumbs';
@@ -80,40 +81,46 @@ export class DraftNew extends Component {
8081
save: this.handleClickSave,
8182
};
8283

84+
const document_title = params.splat
85+
? `New draft - ${params.splat} - Drafts`
86+
: `New draft - Drafts`;
87+
8388
return (
84-
<HotKeys handlers={keyboardHandlers} className="single">
85-
{errors.length > 0 && <Errors errors={errors} />}
86-
<div className="content-header">
87-
<Breadcrumbs type="drafts" splat={params.splat || ''} />
88-
</div>
89-
90-
<div className="content-wrapper">
91-
<div className="content-body">
92-
<InputPath onChange={updatePath} type="drafts" path="" />
93-
<InputTitle onChange={updateTitle} title="" ref="title" />
94-
<MarkdownEditor
95-
onChange={updateBody}
96-
onSave={this.handleClickSave}
97-
placeholder="Body"
98-
initialValue=""
99-
ref="editor"
100-
/>
101-
<Splitter />
102-
<Metadata fields={metafields} />
89+
<DocumentTitle title={document_title}>
90+
<HotKeys handlers={keyboardHandlers} className="single">
91+
{errors.length > 0 && <Errors errors={errors} />}
92+
<div className="content-header">
93+
<Breadcrumbs type="drafts" splat={params.splat || ''} />
10394
</div>
10495

105-
<div className="content-side">
106-
<Button
107-
onClick={this.handleClickSave}
108-
type="create"
109-
active={fieldChanged}
110-
triggered={updated}
111-
icon="plus-square"
112-
block
113-
/>
96+
<div className="content-wrapper">
97+
<div className="content-body">
98+
<InputPath onChange={updatePath} type="drafts" path="" />
99+
<InputTitle onChange={updateTitle} title="" ref="title" />
100+
<MarkdownEditor
101+
onChange={updateBody}
102+
onSave={this.handleClickSave}
103+
placeholder="Body"
104+
initialValue=""
105+
ref="editor"
106+
/>
107+
<Splitter />
108+
<Metadata fields={metafields} />
109+
</div>
110+
111+
<div className="content-side">
112+
<Button
113+
onClick={this.handleClickSave}
114+
type="create"
115+
active={fieldChanged}
116+
triggered={updated}
117+
icon="plus-square"
118+
block
119+
/>
120+
</div>
114121
</div>
115-
</div>
116-
</HotKeys>
122+
</HotKeys>
123+
</DocumentTitle>
117124
);
118125
}
119126
}

src/containers/views/Drafts.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Link } from 'react-router';
44
import { connect } from 'react-redux';
55
import { bindActionCreators } from 'redux';
66
import _ from 'underscore';
7+
import DocumentTitle from 'react-document-title';
78
import Breadcrumbs from '../../components/Breadcrumbs';
89
import Button from '../../components/Button';
910
import InputSearch from '../../components/form/InputSearch';
@@ -121,23 +122,26 @@ export class Drafts extends Component {
121122
const to = params.splat
122123
? `${ADMIN_PREFIX}/drafts/${params.splat}/new`
123124
: `${ADMIN_PREFIX}/drafts/new`;
125+
const title = params.splat ? `${params.splat} | Drafts` : 'Drafts';
124126

125127
return (
126-
<div>
127-
<div className="content-header">
128-
<Breadcrumbs type="drafts" splat={params.splat || ''} />
129-
<div className="draft-buttons">
130-
<Link className="btn btn-active" to={to}>
131-
New draft
132-
</Link>
133-
</div>
134-
<div className="pull-right">
135-
<InputSearch searchBy="filename" search={search} />
128+
<DocumentTitle title={title}>
129+
<div>
130+
<div className="content-header">
131+
<Breadcrumbs type="drafts" splat={params.splat || ''} />
132+
<div className="draft-buttons">
133+
<Link className="btn btn-active" to={to}>
134+
New draft
135+
</Link>
136+
</div>
137+
<div className="pull-right">
138+
<InputSearch searchBy="filename" search={search} />
139+
</div>
136140
</div>
141+
{drafts.length > 0 && this.renderTable()}
142+
{!drafts.length && <h1>{getNotFoundMessage('drafts')}</h1>}
137143
</div>
138-
{drafts.length > 0 && this.renderTable()}
139-
{!drafts.length && <h1>{getNotFoundMessage('drafts')}</h1>}
140-
</div>
144+
</DocumentTitle>
141145
);
142146
}
143147
}

0 commit comments

Comments
 (0)