Skip to content

Commit

Permalink
Switch to using hashRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
kjy5 committed Oct 1, 2023
1 parent 1694465 commit 2e429c8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/components/ArtifactCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "../styles/ArtifactCard.sass";
import { ArtifactData } from "../scripts/interfaces";
import { NavLink } from "react-router-dom";
import { ReactElement } from "react";
import '../styles/ArtifactCard.sass'
import { ArtifactData } from '../scripts/interfaces'
import { NavLink } from 'react-router-dom'
import { ReactElement } from 'react'

/**
* ArtifactPage card component. Displays high-level information about an artifact (title, subtitle, 3D graphic).
Expand All @@ -18,7 +18,7 @@ export default function ArtifactCard(props: {
// Render
return (
/* skipcq: JS-0394 */
<NavLink to={`/honors-portfolio/${id}`} className="artifact-card">
<NavLink to={`/${id}`} className="artifact-card">
<div className="artifact-card__graphic-container" id={id} />
<h1 className="artifact-card__title">{title}</h1>
<h3 className="artifact-card__subtitle">{subtitle}</h3>
Expand Down
26 changes: 13 additions & 13 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import "./styles/index.sass";
import { ArtifactData } from "./scripts/interfaces";
import ArtifactPage from "./routes/ArtifactPage";
import ErrorPage from "./routes/ErrorPage";
import ParseData from "./scripts/parse-data";
import React from "react";
import ReactDOM from "react-dom/client";
import Root from "./routes/Root";
import './styles/index.sass'
import { ArtifactData } from './scripts/interfaces'
import ArtifactPage from './routes/ArtifactPage'
import ErrorPage from './routes/ErrorPage'
import ParseData from './scripts/parse-data'
import React from 'react'
import ReactDOM from 'react-dom/client'
import Root from './routes/Root'
// eslint-disable-next-line sort-imports
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import Graphics from "./scripts/graphics";
import { createHashRouter, RouterProvider } from 'react-router-dom'
import Graphics from './scripts/graphics'

// Parse data and return as an array of ArtifactPage objects
const artifacts: ArtifactData[] = ParseData();

// Create router
const router = createBrowserRouter([
const router = createHashRouter([
{
path: "/honors-portfolio/",
path: "/",
element: <Root />,
errorElement: <ErrorPage fromArtifact={false} />,
loader: () => artifacts,
},
{
path: "/honors-portfolio/:id",
path: ":id",
element: <ArtifactPage />,
errorElement: <ErrorPage fromArtifact />,
loader: ({ params }) => {
Expand Down
14 changes: 7 additions & 7 deletions src/routes/ArtifactPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import "../styles/ArtifactPage.sass";
import { ArtifactData, EmbedData, LinkData } from "../scripts/interfaces";
import { Fragment, ReactElement } from "react";
import { NavLink, useLoaderData } from "react-router-dom";
import Gallery from "../components/Gallery";
import RichLink from "../components/RichLink";
import '../styles/ArtifactPage.sass'
import { ArtifactData, EmbedData, LinkData } from '../scripts/interfaces'
import { Fragment, ReactElement } from 'react'
import { NavLink, useLoaderData } from 'react-router-dom'
import Gallery from '../components/Gallery'
import RichLink from '../components/RichLink'

/**
* Artifact header, displays artifact title, subtitle, date, and links
Expand Down Expand Up @@ -87,7 +87,7 @@ export default function ArtifactPage(): ReactElement {
{/* skipcq: JS-0394 */}
<NavLink
className={"ArtifactPage__return"}
to={"/honors-portfolio"}
to={"/"}
tabIndex={0}
role="button"
>
Expand Down

0 comments on commit 2e429c8

Please sign in to comment.