aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/App.js
blob: ae95dcbc2bc080be1f8b725103638f46269b65c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from 'react';
import NewPaste from './NewPaste'
import ViewPaste from './ViewPaste'
import Footer from './Footer'
import styled from 'styled-components'
import {
  BrowserRouter as Router,
  Switch,
  Route,
  Link,
  useParams
} from "react-router-dom";
import Raw from './renderers/Raw'

const SpacedTitle = styled.div`
    margin-top: 10vh
`

const Desc = () => {
  return (
    <h3>a modern, <a href="https://github.com/jackyzha0/ctrl-v" target="_blank" rel="noopener noreferrer">open-source</a> pastebin with latex and markdown rendering support</h3>
  );
}

const GetPasteWithParam = () => {
  let { hash } = useParams();

  return (
    <ViewPaste hash = {hash} />
  );
}

const GetRawWithParam = () => {
  let { hash } = useParams();

  return (
    <Raw hash={hash} />
  );
}

function App() {
  return (
    <Router>
      <Switch>
        <Route path="/raw/:hash"
          children={<GetRawWithParam />}
        />
        <div className="lt-content-column">
          <SpacedTitle>
            <nav>
              <h1 className="mainLogo">
                <span role="img" aria-label="clipboard">📋&nbsp;</span>
                <Link to="/">ctrl-v</Link>
              </h1>
              <Desc />
            </nav>
          </SpacedTitle>

          <main id="appElement">
            <Switch>
              <Route path="/:hash"
                children={<GetPasteWithParam />}
              />
              <Route path="/">
                <NewPaste />
              </Route>
            </Switch>
          </main>

          <Footer />
        </div>
      </Switch>
    </Router>
  );
}


export default App;