publish: sidebar defensive checks and style fixes

This commit is contained in:
Matilde Park 2020-02-05 20:53:17 -05:00
parent bc4dd57896
commit 6b06367cc4
4 changed files with 37 additions and 24 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17,14 +17,15 @@ export class NotebookItem extends Component {
<Link
to={"/~publish/notebook/" + props.path}>
<div className={"w-100 v-mid f9 pl4 bb " + selectedClass}>
<p className="f9 pt1">{props.title}</p>
<p className="f9 mono gray2">by {props.author}</p>
<p className="f9 pb1">
{postCount}
<span className="green2 ml3">
{unread}
</span>
</p></div>
<p className="f9 pt1">{props.title}</p>
<p className="f9 mono gray2">by {props.author}</p>
<p className="f9 pb1">
{postCount}
<span className="green2 ml3">
{unread}
</span>
</p>
</div>
</Link>
);
}

View File

@ -36,40 +36,52 @@ export class Sidebar extends Component {
case "oldest":
notebooks = new Map(
[...notebooks.entries()].sort(
(a, b) => a[1]["date-created"] - b[1]["date-created"]
(a, b) => {
if ((a[1]) && (b[1])) {
return a[1]["date-created"] - b[1]["date-created"]
}
}
)
);
break;
case "newest":
notebooks = new Map(
[...notebooks.entries()].sort(
(a, b) => b[1]["date-created"] - a[1]["date-created"]
(a, b) => {
if ((a[1]) && (b[1])) {
return b[1]["date-created"] - a[1]["date-created"]
}
}
)
);
break;
case "alphabetical":
notebooks = new Map(
[...notebooks.entries()].sort((a, b) => {
if (a[1]["title"].toLowerCase() < b[1]["title"].toLowerCase()) {
return -1;
if ((a[1]) && (b[1])) {
if (a[1]["title"].toLowerCase() < b[1]["title"].toLowerCase()) {
return -1;
}
if (a[1]["title"].toLowerCase() > b[1]["title"].toLowerCase()) {
return 1;
}
return 0;
}
if (a[1]["title"].toLowerCase() > b[1]["title"].toLowerCase()) {
return 1;
}
return 0;
})
);
break;
case "reverseAlphabetical":
notebooks = new Map(
[...notebooks.entries()].sort((a, b) => {
if (a[1]["title"].toLowerCase() > b[1]["title"].toLowerCase()) {
return -1;
if ((a[1]) && (b[1])) {
if (a[1]["title"].toLowerCase() > b[1]["title"].toLowerCase()) {
return -1;
}
if (a[1]["title"].toLowerCase() < b[1]["title"].toLowerCase()) {
return 1;
}
return 0;
}
if (a[1]["title"].toLowerCase() < b[1]["title"].toLowerCase()) {
return 1;
}
return 0;
})
);
break;