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

Vacms 16105 metatags #269

Merged
merged 8 commits into from
Dec 5, 2023
Merged

Vacms 16105 metatags #269

merged 8 commits into from
Dec 5, 2023

Conversation

ryguyk
Copy link
Contributor

@ryguyk ryguyk commented Dec 5, 2023

Description

Relates to department-of-veterans-affairs/va.gov-cms#16105

Custom meta tags were made available via JSON:API in recent work. This PR places those custom meta tags, along with other global meta tags, on the page.

Testing done

Manual; see QA steps

QA steps

  • Visit a number of different page types and ensure meta tags are in the page markup
    • News story
    • Lovell news story
    • Story listing
    • Lovell story listing

- Updates types for news stories and story listings to include metatag prop.
- Updates tests/mock data to accommodate metatag prop.
- Adds newly created <Meta> component to [[...slug]].tsx
@va-cms-bot va-cms-bot temporarily deployed to Tugboat December 5, 2023 02:07 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat December 5, 2023 02:15 Destroyed
id: string
context?: GetServerSidePropsContext
Copy link
Contributor Author

@ryguyk ryguyk Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The QueryOpts type definition provided by next-drupal doesn't seem correct to me.

export declare type QueryOpts<Options> = Options & {
    context?: GetStaticPathsContext | GetServerSidePropsContext;
};

It seems like it should be context?: GetStaticPropsContext | GetServerSidePropsContext. After all, we are querying data from within getStaticProps and, as such, passing in a GetStaticPropsContext property. So, our query functions need to accept a context that is of type GetStaticPropsContext.

We have a lot of instances of QueryOpts<{some type definition}>, but, for now, I simply removed this from stories and story listings and explicitly added the context property with the type we want (ExpandedStaticPropsContext, which is a decorated form of GetStaticPropsContext). We'll need to address the other instances later.

@va-cms-bot va-cms-bot temporarily deployed to Tugboat December 5, 2023 02:26 Destroyed
export const generateAbsoluteUrlFromEnv = (relativeUrl: string) =>
generateAbsoluteUrlFromBuildType(
relativeUrl,
process.env.NEXT_PUBLIC_BUILD_TYPE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we may want to use APP_ENV over NEXT_PUBLIC_BUILD_TYPE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment. I'm not sure either of these is ultimately what we want. I think this is a bit deeper. The rhetorical question I would ask is, what is the value of APP_ENV on Tugboat?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's tugboat, so naively I thought something like:

  TUGBOAT: 'tugboat',

  [environments.TUGBOAT]: {
    hostname: process.env.TUGBOAT_DEFAULT_SERVICE_URL_HOST,
    origin: process.env.TUGBOAT_DEFAULT_SERVICE_URL,
  },

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is clarifying. I need to chew on things still, but this helps paint the picture of your vision.

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="canonical"
href={generateAbsoluteUrlFromEnv(canonicalLink)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that generateAbsoluteUrlFromEnv() is working as intended

Screenshot 2023-12-04 at 8 29 55 PM
Both og:url and the <link rel="canonical" href="..."> seem to be relative only, which returns if the build type is not valid (currently NEXT_PUBLIC_BUILD_TYPE)

Copy link
Contributor Author

@ryguyk ryguyk Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relates to the discussion in Slack.

This will not work right now. We need to do some work to nail down what different ENV vars mean, and how we are going to use them.

This was an initial pass, but I'm now thinking we should not be using NEXT_PUBLIC_BUILD_TYPE or NEXT_PHASE or any generic environment identifier to generate absolute URLs. A dev vs. prod build says very little about where the build will ultimately live. We can do a production build locally, and we should still be able to generate local URLs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, completely agree

I think ultimately we will need some separate options handling from the .env files, something like: department-of-veterans-affairs/va.gov-cms#15322 (analogous to the cli options available to content build https://github.com/department-of-veterans-affairs/content-build/blob/main/src/site/stages/build/options.js )

@ryguyk ryguyk marked this pull request as ready for review December 5, 2023 16:00
@va-cms-bot va-cms-bot temporarily deployed to Tugboat December 5, 2023 19:13 Destroyed
@va-cms-bot va-cms-bot temporarily deployed to Tugboat December 5, 2023 19:56 Destroyed
…URLs. This needs more consideration going forward, but it is good for now.
@ryguyk ryguyk force-pushed the VACMS-16105-metatags branch from c7a94f9 to 2567b6a Compare December 5, 2023 20:31
@va-cms-bot va-cms-bot temporarily deployed to Tugboat December 5, 2023 20:31 Destroyed
@tjheffner tjheffner merged commit 6f61b56 into main Dec 5, 2023
5 of 6 checks passed
@tjheffner tjheffner deleted the VACMS-16105-metatags branch December 5, 2023 20:53
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

Successfully merging this pull request may close these issues.

3 participants