Skip to content

Commit

Permalink
🔥 Remove rootPath function
Browse files Browse the repository at this point in the history
  • Loading branch information
lukew3 committed Aug 16, 2022
1 parent 8c11987 commit 4128539
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 23 deletions.
7 changes: 3 additions & 4 deletions components/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Link from 'next/link';
import styles from '../styles/Nav.module.css'
import { useEffect, useState } from 'react';
import dynamic from 'next/dynamic';
import { rootPath } from '../utils/lib';

const NavLogin = dynamic(() => import('./navLogin'), {
ssr: false,
Expand All @@ -13,17 +12,17 @@ const Nav = () => {

return (
<nav className={styles.nav_cont}>
<Link href={`${rootPath()}/`}>
<Link href={`/`}>
<a><h1 className={styles.title_link}>3cards</h1></a>
</Link>
<div className={styles.nav_right}>
<Link href={`${rootPath()}/sets`}>
<Link href={`/sets`}>
<a>
<img src="/images/search.svg" className={styles.nav_svg}/>
<label className={styles.nav_label}>Find Sets</label>
</a>
</Link>
<Link href={`${rootPath()}/create`}>
<Link href={`/create`}>
<a>
<img src="/images/plus.svg" className={styles.nav_svg}/>
<label className={styles.nav_label}>Create Set</label>
Expand Down
4 changes: 1 addition & 3 deletions components/navLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { ArweaveWebWallet } from 'arweave-wallet-connector';
import Link from 'next/link';
import styles from '../styles/Nav.module.css'
import ConnectFloater from './connectFloater';
import { rootPath } from '../utils/lib';


const NavLogin = (props: {
loggedIn: boolean,
Expand Down Expand Up @@ -52,7 +50,7 @@ const NavLogin = (props: {
className={styles.login_text}
>
{props.loggedIn ?
<Link href={{ pathname: `${rootPath()}/sets`, query: { owner: address } }}>
<Link href={{ pathname: `/sets`, query: { owner: address } }}>
<a>
<img src="/images/user.svg" className={styles.nav_svg} />
<label className={styles.nav_label}>My Sets</label>
Expand Down
5 changes: 2 additions & 3 deletions components/sets/setInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Link from 'next/link';
import styles from '../../styles/sets/SetInfo.module.css'
import { rootPath } from '../../utils/lib';

interface SetData {
tx_id: string,
Expand All @@ -15,11 +14,11 @@ const SetInfo = (props: {
set: SetData
}) => {
const buildSetLink = () : string => {
return `${rootPath()}/set?tx_id=${ props.set.tx_id }`
return `/set?tx_id=${ props.set.tx_id }`
}

const buildAddressLink = () : string => {
return `${rootPath()}/sets?owner=${ props.set.owner_address }`;
return `/sets?owner=${ props.set.owner_address }`;
}

const buildShortAddress = () : string => {
Expand Down
5 changes: 2 additions & 3 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { NextPage } from 'next'
import Head from 'next/head'
import Link from 'next/link'
import styles from '../styles/Home.module.css'
import { rootPath } from '../utils/lib';

const Home: NextPage = () => {
return (
Expand All @@ -15,10 +14,10 @@ const Home: NextPage = () => {
<h3 className={styles.main_desc}>Flashcards Without the Middleman</h3>
<p className={styles.sub_desc}>No ads, no paywalls, no takedowns</p>
<div className={styles.buttons_group}>
<Link href={`${rootPath()}/sets`}>
<Link href={`/sets`}>
<a className={styles.button}>Browse Sets</a>
</Link>
<Link href={`${rootPath()}/create`}>
<Link href={`/create`}>
<a className={styles.button}>Create a set</a>
</Link>
</div>
Expand Down
3 changes: 1 addition & 2 deletions pages/sets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useRouter } from 'next/router';
import Link from 'next/link';
import SetInfo from '../components/sets/setInfo';
import styles from '../styles/sets/Sets.module.css';
import { rootPath } from '../utils/lib';

interface SetData {
tx_id: string,
Expand Down Expand Up @@ -128,7 +127,7 @@ const Set: NextPage = () => {
</div>
<div className={styles.page_control}>
<p>&lt;</p>
<Link href={`${rootPath()}${buildNextUrl()}`}>
<Link href={`${buildNextUrl()}`}>
<p>&gt;</p>
</Link>
</div>
Expand Down
8 changes: 0 additions & 8 deletions utils/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,3 @@ export async function loadSet(tx_id : string) {
})
return set;
}

export function rootPath() : string {
try {
return (location.pathname.split('/').length > 2) ? '/' + location.pathname.split('/')[1] : '';
} catch (e) {
return '';
}
}

0 comments on commit 4128539

Please sign in to comment.