Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getPageTitle helper to the PageTitle component #387

Open
nozomione opened this issue Oct 15, 2024 · 0 comments
Open

Add getPageTitle helper to the PageTitle component #387

nozomione opened this issue Oct 15, 2024 · 0 comments
Assignees

Comments

@nozomione
Copy link
Member

nozomione commented Oct 15, 2024

Context

Currently, we use a switch statement and regex patterns to determine the prefix for each page's <title /> HTML tag
for SEO in the PageTitle component.

  switch (true) {
    case title.length > 0:
      pageTitle = `${title}`
      break
    case home:
      pageTitle = `${appName} - Search for harmonized transcriptome data`
      break
    case /\/about$/.test(path):
      pageTitle = `About`
      break
    case /\/dataset/.test(path):
      pageTitle = `Dataset -`
      break
    case /\/download/.test(path):
      pageTitle = `Download Dataset -`
      break
    case /\/license$/.test(path):
      pageTitle = `License -`
      break
    case /\/privvacy$/.test(path):
      pageTitle = `Privacy -`
      break
    case /\/terms$/.test(path):
      pageTitle = `Terms of Use -`
      break
    default:
      break
  }

In this issue, we want to replace the switch with an if statement, and instead of using regex, we'll define all prefix values for the pages using an object.

Problem or idea

To achieve this, we should make the following changes to PageTitle:

  • Add a new object containing all possible prefixes for the pages
  • Add a new helper method that returns the appropriate prefix based on the route values

Solution or next step

In PageTitle:

  1. Add a new constant object,titlePrefixes, to store prefix values for pages
  2. Add a new helper getPageTitle that does the following:
    • Takes a route path as its argument
    • Returns the corresponding prefix value using if and titlePrefixes
@nozomione nozomione self-assigned this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant