Dawn of the Final Day -24 Hours Remain- 
Tags: opensource, react, typescript
Published: 2020-12-10 22:24:14

The semester from Hell is nearly over, thank the gods. Only 24 hours remain (well, more or less) until I'm finally free for a whole month. And yet I still have another assignment to do, Santa have mercy.

___

This will serve as my third and final blog post for release 0.4 for my Open Source Development class (_You can read the first blog post [here](https://dev.to/chrispinkney/dawn-of-the-final-day-3-releases-remain-i1n) and the second one [here](https://dev.to/chrispinkney/title-stuck-in-the-middle-with-me-112l)._) It's been a blast but the party is over and everyone wants to go home, [so grab your gun and bring the cat in](https://www.youtube.com/watch?v=zmqdsFq9fgs).

So I originally set out on my journey to implement a global stylesheet configuration for the new NextJS frontend. We already had one for the Gatsby side of things but since we're switching to NextJS all the styling needed to be ported over as well. I spent a few hours doing TypeScript and NextJS tutorials (two things I know nothing about) to brush up on what needs to get done for this PR. I figured out how to create a top level component which will import and force a global CSS file onto any page across the entire web app, but only after I researched this stuff did I realize that Gatsby's [`PageBase.js`](https://github.com/Seneca-CDOT/telescope/blob/master/src/frontend/gatsby/src/pages/PageBase.js) file (the file in charge of doing that) does much more than that (SEO) and requires more work in order to fully implement a global config. Since Gatsby uses MaterialUI (something else I also researched) that had to be created first. Then SEO. Then global config. Then styling. Oof. I may have bitten off more than I could chew for this. I decided to tackle something else in the mean time and get back to this if I could.

My next task was to reimplement an `about` page for the NextJS port. Seems easy enough.

As usual I started out my hunt for a solution with a bit of reconnaissance. I wanted to learn how Gatsby rendered the [about](https://github.com/Seneca-CDOT/telescope/blob/master/src/frontend/gatsby/src/markdown-pages/about.md) page. Oddly enough, it redirects the about route directly to the md page and renders it. Isn't that neat? A bit inconsistent with how every other page component is created in the project, but really cool nonetheless. It does this using [GraphQL and something called slugs](https://github.com/Seneca-CDOT/telescope/blob/master/src/frontend/gatsby/gatsby-node.js#L114), two things I also had to learn a bit about... sooo, how can I do this with NextJS? We aren't using GraphQL so the duo idea between that and generating slug pages seemed out of the question. I decided to look at how NextJS handles rendering `.md` files, which wasn't as easy as I figured it would be. Eventually I stumbled upon a library that rendered `.mdx` files, which are just fancy `.md` files that can have JSX/TSX code injected directly into them! Seems perfect and really interesting, so I tried it out.

I also think this approach pairs really nicely with how NextJS renders routes based on present files. All I had to do was place the `.mdx` file in our `Pages`  directory and navigate to `localhost:8000/about` to render it. We don't even need a slug library anymore because it just works. I also created a simple component which returns a the word Hello styled in blue, and called it in the `.mdx` file:

```JS
const h2Style = {
  color: 'blue',
  textDecoration: 'none',
};

const hello = () => {
  return <h2 style={h2Style}>Hello</h2>;
};

export default hello;
```

```MD
import Hello from './hello';

<Hello />

## About

One of the key features[...]
```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uznydbqb1kv4ve30lodm.png)

Amazingly, it just worked. The page obviously requires styling but we'll get around to that when we get around to that. Cool. Figuring out the config file for `next.config.js` was easy and interesting. [You can see the entire PR here](https://github.com/Seneca-CDOT/telescope/pull/1487). Hopefully I don't get yelled at for introducing a dependency. I think this is a neat approach though, we can also use this library to further add `.mdx` files in the future (*documentation, etc, who knows?*) Next. (*heh*)



My second issue was reimplementing a Logo component which accepts a height and width as props and generates a logo on command. Perfect! NextJS just came out. I remember watching the release conference and being excited by them talking about automatic lazy loading and image optimization as big highlights of version 10.0.0, so I was keen on reading up about how the new technology works and how to implement it. I also was curious about the `.webp` file format so I decided to convert our `.svg` logo to `.webp` in Photoshop to play around with it. Simply getting the image to even display on screen surprisingly not as easy as I thought it was. If eslint was fighting with me about not being able to resolve the path (*even when the image would actually display*) then NextJS just was not displaying the image at all.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5hpn05r9mkdnd9ltn5r5.png)

I found [a library](https://github.com/twopluszero/next-images) that allowed for easier image imports in a NextJS app. Again I'm hesitant about introducing yet another stupid dependency, but couldn't figure out an alternative that would make everyone happy, seems like NextJS has no problem importing images from a CDN but struggled to safely import them locally. Eventually I figured out how to pass props between a component and a main page and the logo finally displayed in all its glory:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/o6qumdne8iujdep3z22i.gif)

I made a PR which [you can see here](https://github.com/Seneca-CDOT/telescope/pull/1513). Afterwards I also had [some help from my new friend Tony](https://github.com/Seneca-CDOT/telescope/pull/1513#discussion_r540237705) (*who is already a better developer than I'll ever be*) who showed me how to properly specify a prop's type, which was I apparently doing wrong [here](https://github.com/Seneca-CDOT/telescope/pull/1513/commits/e99bbed2e2d09c99438192d0edcac4f6df1a166c#diff-34a9f72e2c7924aeec5b035de79047727df184be039b18f3dbafba7b73fd16fcR6), so I fixed the issue and made a new commit. Thanks Tony, and see you in January! TypeScript is neat, but kind of quirky.

And with those two smol PRs, that about wraps up all the time I have for my release 0.4 assignment.

___

Overall in release 0.4 I didn't face too many challenges, which is honestly upsetting to me. I had three weeks and I set out with the goal of doing a bunch of small sized issues to reintroduce myself to the lovely world of Web Programming. I wanted to do 5 PRs, which quickly became 4 PRs... then 3, and, you know how it ended. But hey, at least I learned a bunch and, as always, had fun doing it.

Oh, and I did (*kind of?*) a review of a PR [here](https://github.com/Seneca-CDOT/telescope/pull/1444#issuecomment-733421393). I was really excited about this merge to master that I wanted to try it when it was available. Josue was kind enough to help me out with some questions I had with it. He's a really swell guy.

___

Anyway that about wraps it up. My plans for the Christmas break include eating, drinking, sleeping, being merry, dual-booting Linux, learning React, formatting my pc, [shuckin' some 8TB drives](https://tv.getyarn.io/yarn-clip/372374fb-79d0-4fc4-a8f6-d7b312ba558b) and updating my FreeNAS server, and playing Cyberpunk.

Oh and the video game awards are tonight at 615pm EST, you can [watch it here](https://www.youtube.com/watch?v=zWz6v-UAs8Q). I'll be at work but fortunately I work from home so I can just glance over at it.

Now I have to run and help finish a group for a presentation tomorrow morning.

Tune in January to see my progress in the successor to this course, [OSD700](https://apps.senecacollege.ca/ssos/findOutline.do?subjectCode=OSD700)!