AlexsLemonade / AlexsLemonade/refinebio-web

Add getPageTitle helper to the PageTitle component

Open
#387 0 comments 0 reactions 1 assignee View on GitHub

@nozomione is already working on this.

Since Oct 15, 2024.

Post QA
Dominant language
JavaScript
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.