Skip to content

Commit

Permalink
Use about paths that match existing website
Browse files Browse the repository at this point in the history
- /about/project -> /about
- /about/press -> /press
- /about/share -> /sharing
- /about/data -> /data + /datasets (combines both pages)
  Deprecated alternate paths /maps and /inventories are ignored.
- /about/dataset/:id -> /imports/:id

See #246.
  • Loading branch information
ezwelty committed Dec 27, 2022
1 parent eeb12fe commit 0cc063a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
18 changes: 9 additions & 9 deletions src/components/about/ProjectPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ const Project = () => (
world's most comprehensive. While our users contribute locations of
their own, we comb the internet for pre-existing knowledge, seeking to
unite the efforts of foragers, foresters, and freegans everywhere. The{' '}
<a href="/about/data">imported datasets</a> range from small
neighborhood foraging maps to vast professionally-compiled tree
inventories. This so far amounts to thousands of different types of
edibles (most, but not all, plant species) distributed over millions
of locations. Beyond the cultivated and commonplace to the exotic
flavors of foreign plants and long-forgotten native plants, foraging
in your neighborhood is a journey through time and across cultures.
<a href="/data">imported datasets</a> range from small neighborhood
foraging maps to vast professionally-compiled tree inventories. This
so far amounts to thousands of different types of edibles (most, but
not all, plant species) distributed over millions of locations. Beyond
the cultivated and commonplace to the exotic flavors of foreign plants
and long-forgotten native plants, foraging in your neighborhood is a
journey through time and across cultures.
</p>
<p>
Join us in celebrating hyper-local food! The <a href="/map">map</a> is
open for anyone to edit, the database can be{' '}
<a href="/about/data">downloaded</a> with just one click, and the{' '}
<a href="/data">downloaded</a> with just one click, and the{' '}
<a href="https://github.com/falling-fruit">code</a> is open-source.
You are likewise encouraged to share the bounty with your fellow
humans. Our <a href="/about/share">sharing page</a> lists hundreds of
humans. Our <a href="/sharing">sharing page</a> lists hundreds of
local organizations - planting public orchards and food forests,
picking otherwise-wasted fruits and vegetables from city trees and
farmers' fields, and sharing with neighbors and the needy.
Expand Down
14 changes: 8 additions & 6 deletions src/components/about/aboutRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,28 @@ import ShareTheHarvestPage from './ShareTheHarvestPage'

const pages = [
{
path: '/about/project',
path: ['/about'],
component: ProjectPage,
},
{
path: '/about/dataset/:id',
path: ['/imports/:id'],
component: AboutDatasetPage,
},
{
path: '/about/data',
path: ['/data', '/datasets'],
component: DataPage,
},
{
path: '/about/press',
path: ['/press'],
component: InThePressPage,
},
{
path: '/about/share',
path: ['/sharing'],
component: ShareTheHarvestPage,
},
]

const aboutRoutes = pages.map((props) => <Route key={props.path} {...props} />)
const aboutRoutes = pages.map((props) => (
<Route key={props.path[0]} {...props} />
))
export default aboutRoutes
17 changes: 11 additions & 6 deletions src/components/desktop/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { CaretDown } from '@styled-icons/boxicons-regular'
import { User } from '@styled-icons/boxicons-solid'
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import { Link, NavLink, useRouteMatch } from 'react-router-dom'
import { matchPath } from 'react-router'
import { Link, NavLink, useLocation, useRouteMatch } from 'react-router-dom'
import styled from 'styled-components/macro'

import { logout } from '../../redux/authSlice'
import aboutRoutes from '../about/aboutRoutes'
import Button from '../ui/Button'
import ResetButton from '../ui/ResetButton'

Expand Down Expand Up @@ -184,7 +186,10 @@ const Header = () => {
dispatch(logout())
}

const isAboutPage = useRouteMatch('/about/:slug') !== null
const isAboutPage =
matchPath(useLocation().pathname, {
path: aboutRoutes.map((route) => route.props.path).flat(),
}) !== null
const isAccountPage = useRouteMatch('/account') !== null

return (
Expand All @@ -201,16 +206,16 @@ const Header = () => {
</li>
<li>
<StyledDropdown label={t('About')} isMatch={isAboutPage}>
<NavLink to="/about/project" activeClassName="active">
<NavLink to="/about" activeClassName="active">
{t('The project')}
</NavLink>
<NavLink to="/about/data" activeClassName="active">
<NavLink to="/data" activeClassName="active">
{t('The data')}
</NavLink>
<NavLink to="/about/share" activeClassName="active">
<NavLink to="/sharing" activeClassName="active">
{t('Sharing the harvest')}
</NavLink>
<NavLink to="/about/press" activeClassName="active">
<NavLink to="/press" activeClassName="active">
{t('In the press')}
</NavLink>
</StyledDropdown>
Expand Down
2 changes: 1 addition & 1 deletion src/components/entry/EntryOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const EntryOverview = ({ locationData, className }) => {
{t('Imported from')}{' '}
<Link
to={{
pathname: `/about/dataset/${locationData.import_id}`,
pathname: `/imports/${locationData.import_id}`,
state: { fromPage: `/entry/${locationData.id}` },
}}
>
Expand Down
8 changes: 4 additions & 4 deletions src/components/settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,22 @@ const SettingsPage = ({ desktop }) => {
<StyledListEntry
rightIcons={<ChevronRight size="16" color={theme.blue} />}
primaryText={'The project'}
onClick={() => history.push('/about/project')}
onClick={() => history.push('/about')}
/>
<StyledListEntry
rightIcons={<ChevronRight size="16" color={theme.blue} />}
primaryText={'The data'}
onClick={() => history.push('/about/data')}
onClick={() => history.push('/data')}
/>
<StyledListEntry
rightIcons={<ChevronRight size="16" color={theme.blue} />}
primaryText={'Sharing the harvest'}
onClick={() => history.push('/about/share')}
onClick={() => history.push('/sharing')}
/>
<StyledListEntry
rightIcons={<ChevronRight size="16" color={theme.blue} />}
primaryText={'In the press'}
onClick={() => history.push('/about/press')}
onClick={() => history.push('/press')}
/>
</>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/table/ImportsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ const ImportsTable = () => {
persistTableHead
onRowClicked={(row) => {
history.push({
pathname: `/about/dataset/${row.id}`,
state: { fromPage: '/about/datasets' },
pathname: `/imports/${row.id}`,
state: { fromPage: '/data' },
})
}}
/>
Expand Down

0 comments on commit 0cc063a

Please sign in to comment.