Skip to content

Commit d6bbbfc

Browse files
committed
Title fix for RecentSnippetItem and Snippet
To keep consistent title and to follow existing behaviour. So now if title is undefined Its id and Undefined word will appear
1 parent c2bc0ae commit d6bbbfc

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/components/RecentSnippetItem.jsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import React from 'react';
22
import { Link } from 'react-router-dom';
33

4-
const RecentSnippetItem = ({ snippet }) => (
5-
<li className="recent-snippet-item">
6-
<div className="recent-snippet-data">
4+
const RecentSnippetItem = ({ snippet }) => {
5+
const snippetTitle = snippet.get('title') || `#${snippet.get('id')}, Untitled`;
6+
7+
return (
8+
<li className="recent-snippet-item">
9+
<div className="recent-snippet-data">
10+
<div>
11+
<span className="recent-snippet-data-title">{snippetTitle}</span>
12+
<span className="recent-snippet-data-lang">[ {snippet.get('syntax', 'Text')} ]</span>
13+
</div>
14+
<span className="recent-snippet-data-author">By Guest</span>
15+
</div>
716
<div>
8-
<span className="recent-snippet-data-title">{snippet.get('title')}</span>
9-
<span className="recent-snippet-data-lang">[ {snippet.get('syntax', 'Text')} ]</span>
17+
<button className="recent-snippet-button light">Raw</button>
18+
<button className="recent-snippet-button light">Download</button>
19+
<Link to={`${snippet.get('id')}`} className="recent-snippet-button">Show</Link>
1020
</div>
11-
<span className="recent-snippet-data-author">By Guest</span>
12-
</div>
13-
<div>
14-
<button className="recent-snippet-button light">Raw</button>
15-
<button className="recent-snippet-button light">Download</button>
16-
<Link to={`${snippet.get('id')}`} className="recent-snippet-button">Show</Link>
17-
</div>
18-
</li>
19-
);
21+
</li>
22+
);
23+
};
2024

2125
export default RecentSnippetItem;

src/components/Snippet.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Snippet extends React.Component {
3434

3535
if (!snippet) return <Spinner />;
3636

37-
const snippetTitle = snippet.get('title') ? snippet.get('title') : `#${snippet.get('id')}, Untitled`;
37+
const snippetTitle = snippet.get('title') || `#${snippet.get('id')}, Untitled`;
3838

3939
return (
4040
[

0 commit comments

Comments
 (0)