Skip to content

Commit

Permalink
fix(landing): remove ssr from index (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz authored Nov 23, 2021
1 parent 63fe5c3 commit c7e7f2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
13 changes: 0 additions & 13 deletions website/landing/pages/api/hello.ts

This file was deleted.

26 changes: 9 additions & 17 deletions website/landing/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Users } from "../components/Users";
import { styled } from "../stitches.config";
import content from "../website.config.json";

const DEFAULT_HOST = "";
const DEFAULT_HOST = "https://sandpack.codesandbox.io";

const Container = styled("section", {
display: "flex",
Expand All @@ -32,11 +32,8 @@ const Main = styled("main", {
interface HomeProps {
host: string | undefined;
}
const Home: NextPage<HomeProps> = ({ host }) => {
const Home: NextPage<HomeProps> = () => {
const { global, meta } = content;
const HOST_URL = host
? `${host.includes("localhost") ? "http" : "https"}://${host}`
: DEFAULT_HOST;

return (
<Container>
Expand All @@ -47,11 +44,13 @@ const Home: NextPage<HomeProps> = ({ host }) => {

{/* Open Graph */}
{meta.map(({ name, value }) => {
const content =
{
"og:url": HOST_URL,
"og:image": `${HOST_URL}/${value}`,
}[name] || value;
let content = value;

if (name === "og:url") {
content = `${DEFAULT_HOST}/${content}`;
} else if (name === "og:image") {
content = DEFAULT_HOST;
}

return <meta key={name} content={content} name={name} />;
})}
Expand All @@ -72,11 +71,4 @@ const Home: NextPage<HomeProps> = ({ host }) => {
);
};

Home.getInitialProps = async (context) => {
const { req } = context;
const host = req?.headers.host;

return { host };
};

export default Home;

0 comments on commit c7e7f2e

Please sign in to comment.