mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-26 13:45:30 +03:00
404: removes bespoke 404 on profile and slate public
This commit is contained in:
parent
eed12b2448
commit
6e8e430352
@ -52,62 +52,24 @@ const STYLES_USER = css`
|
||||
|
||||
export default class ProfilePage extends React.Component {
|
||||
render() {
|
||||
const title = this.props.creator
|
||||
? `@${this.props.creator.username}`
|
||||
: "404";
|
||||
const title = this.props.creator ? `@${this.props.creator.username}` : "404";
|
||||
const url = `https://slate.host/${title}`;
|
||||
|
||||
if (!this.props.creator) {
|
||||
return (
|
||||
<WebsitePrototypeWrapper
|
||||
title={title}
|
||||
description="This Slate user can not be found."
|
||||
url={url}
|
||||
>
|
||||
<div css={STYLES_ROOT}>
|
||||
<h1 css={STYLES_HEADING}>404</h1>
|
||||
<p css={STYLES_PARAGRAPH}>
|
||||
This user is not found.
|
||||
<br />
|
||||
<br />
|
||||
<a href="/application">Run Slate {Constants.values.version}</a>
|
||||
<br />
|
||||
<a href="/system">Use Slate's Design System</a>
|
||||
</p>
|
||||
</div>
|
||||
</WebsitePrototypeWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
const description = "A user on Slate.";
|
||||
|
||||
return (
|
||||
<WebsitePrototypeWrapper
|
||||
title={title}
|
||||
description={description}
|
||||
url={url}
|
||||
image={this.props.creator.data.photo}
|
||||
>
|
||||
<WebsitePrototypeWrapper title={title} description={description} url={url} image={this.props.creator.data.photo}>
|
||||
<div css={STYLES_ROOT}>
|
||||
<div
|
||||
css={STYLES_USER}
|
||||
style={{ backgroundImage: `url(${this.props.creator.data.photo})` }}
|
||||
/>
|
||||
<div css={STYLES_USER} style={{ backgroundImage: `url(${this.props.creator.data.photo})` }} />
|
||||
<h1 css={STYLES_HEADING}>{title}</h1>
|
||||
<p css={STYLES_PARAGRAPH}>
|
||||
This is an example of a profile page on Slate. Slate is going to be
|
||||
really cool soon!
|
||||
This is an example of a profile page on Slate. Slate is going to be really cool soon!
|
||||
<br />
|
||||
<br />
|
||||
{this.props.creator.slates.map((row) => {
|
||||
const url = `https://slate.host/@${this.props.creator.username}/${
|
||||
row.slatename
|
||||
}`;
|
||||
const url = `https://slate.host/@${this.props.creator.username}/${row.slatename}`;
|
||||
return (
|
||||
<React.Fragment key={url}>
|
||||
<a href={`/@${this.props.creator.username}/${row.slatename}`}>
|
||||
{url}
|
||||
</a>
|
||||
<a href={`/@${this.props.creator.username}/${row.slatename}`}>{url}</a>
|
||||
<br />
|
||||
</React.Fragment>
|
||||
);
|
||||
@ -118,9 +80,7 @@ export default class ProfilePage extends React.Component {
|
||||
<br />
|
||||
<a href="/system">Use Slate's Design System</a>
|
||||
<br />
|
||||
<a href="https://github.com/filecoin-project/slate">
|
||||
View Source ☺
|
||||
</a>
|
||||
<a href="https://github.com/filecoin-project/slate">View Source ☺</a>
|
||||
</p>
|
||||
</div>
|
||||
</WebsitePrototypeWrapper>
|
||||
|
@ -35,13 +35,7 @@ export default class SlatePage extends React.Component {
|
||||
name: "slate-global-create-carousel",
|
||||
detail: {
|
||||
slides: this.props.slate.data.objects.map((each) => {
|
||||
return (
|
||||
<img
|
||||
key={each.id}
|
||||
src={each.url}
|
||||
style={{ maxHeight: "80%", maxWidth: "80%", display: "block" }}
|
||||
/>
|
||||
);
|
||||
return <img key={each.id} src={each.url} style={{ maxHeight: "80%", maxWidth: "80%", display: "block" }} />;
|
||||
}),
|
||||
},
|
||||
});
|
||||
@ -54,34 +48,8 @@ export default class SlatePage extends React.Component {
|
||||
});
|
||||
|
||||
render() {
|
||||
const title = this.props.slate
|
||||
? `@${this.props.slate.ownername}/${this.props.slate.slatename}`
|
||||
: "404";
|
||||
const title = this.props.slate ? `@${this.props.slate.ownername}/${this.props.slate.slatename}` : "404";
|
||||
const url = `https://slate.host/${title}`;
|
||||
|
||||
if (!this.props.slate) {
|
||||
return (
|
||||
<WebsitePrototypeWrapper
|
||||
title={title}
|
||||
description="This Slate can not be found."
|
||||
url={url}
|
||||
>
|
||||
<div css={STYLES_ROOT}>
|
||||
<System.H1>404</System.H1>
|
||||
<br />
|
||||
<System.P>
|
||||
This slate is not found.
|
||||
<br />
|
||||
<br />
|
||||
<a href="/application">Run Slate {Constants.values.version}</a>
|
||||
<br />
|
||||
<a href="/system">Use Slate's Design System</a>
|
||||
</System.P>
|
||||
</div>
|
||||
</WebsitePrototypeWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
const description = "A slate.";
|
||||
|
||||
let image;
|
||||
@ -90,17 +58,9 @@ export default class SlatePage extends React.Component {
|
||||
}
|
||||
|
||||
return (
|
||||
<WebsitePrototypeWrapper
|
||||
title={title}
|
||||
description={description}
|
||||
url={url}
|
||||
image={image}
|
||||
>
|
||||
<WebsitePrototypeWrapper title={title} description={description} url={url} image={image}>
|
||||
<div css={STYLES_ROOT}>
|
||||
<Slate
|
||||
items={this.props.slate.data.objects}
|
||||
onSelect={this._handleSelect}
|
||||
/>
|
||||
<Slate items={this.props.slate.data.objects} onSelect={this._handleSelect} />
|
||||
</div>
|
||||
<System.GlobalCarousel />
|
||||
</WebsitePrototypeWrapper>
|
||||
|
27
server.js
27
server.js
@ -56,18 +56,23 @@ app.prepare().then(async () => {
|
||||
username: req.params.username,
|
||||
});
|
||||
|
||||
if (!creator) {
|
||||
return res.redirect("/404");
|
||||
}
|
||||
|
||||
if (creator.error) {
|
||||
return res.redirect("/404");
|
||||
}
|
||||
|
||||
const slates = await Data.getSlatesByUserId({ userId: creator.id });
|
||||
|
||||
return app.render(req, res, "/profile", {
|
||||
viewer,
|
||||
creator:
|
||||
creator && !creator.error
|
||||
? {
|
||||
username: creator.username,
|
||||
data: { photo: creator.data.photo },
|
||||
slates: JSON.parse(JSON.stringify(slates)),
|
||||
}
|
||||
: null,
|
||||
creator: {
|
||||
username: creator.username,
|
||||
data: { photo: creator.data.photo },
|
||||
slates: JSON.parse(JSON.stringify(slates)),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@ -76,12 +81,12 @@ app.prepare().then(async () => {
|
||||
slatename: req.params.slatename,
|
||||
});
|
||||
|
||||
if (slate) {
|
||||
slate.ownername = req.params.username;
|
||||
if (!slate) {
|
||||
return res.redirect("/404");
|
||||
}
|
||||
|
||||
return app.render(req, res, "/slate", {
|
||||
slate: JSON.parse(JSON.stringify(slate)),
|
||||
slate: JSON.parse(JSON.stringify({ ...slate, ownername: req.params.username })),
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user