Please visit https://gitlab.com/chennisden/dennisc.net instead
Thie is the GitHub repository for my website. All the code that runs my website is here. Currently, there's no backend, so I don't ever deal with that. (I don't anticipate ever needing a backend.)
My stack is
React JS + Next JS + Tailwind CSS
I cannot make this clear enough: these elements are completely orthogonal. There are tools that make them play better together, but these tools do not serve the same purpose.
In particular, React is the framework, Next is used for rendering (it takes a hybrid server-side and client-side rendering approach), and Tailwind is used for styling the frontend.
This project is using yarn
as its package manager.
Clone the repository and run yarn dev
.
Very roughly, this follows Tania Rascia's guide.
- public: Any files I want the public to be able to view
(hence the name).
- resources: PDFs that would be filed under math.
- reports: PDFs that would be filed under writing.
- styles: Self-explanatory.
- components: Anything that is mostly visual. Lines can get a little blurry between components and utils.
- utils: Anything more complicated than a slew of
<div className="...">
Currently used for dynamic routing, comments, etc. - posts: Here, all the
.mdx
files for my writing are contained. The pages are read via some functions inutils
and rendered with[slug].tsx
. (The page rendering function called in[slug].tsx
is also inutils
.) - pages: Pages that are not part of the blog; that is, anything in the main website.
- home: Any pages in the index directory that I think are easier written with Markdown.
The blog is compiled and rendered via the help of Next JS.
Here's how it works.
- An interface called
Page
is created inpage.ts
. - Every
.mdx
file in a particular directory (which is passed in, because I have three blog secttions) has its filepath read in theAllPages(dir)
function inside ofapi/GetPages.ts
. - Using
graymatter
, we strip out the metadata so we can display it on the pages. This data is placed into an instance of thePage
interface. This is also done inapi/GetPages.ts
. - In
api/GetPages.ts
, a sorting function will be created based on date. Because of a few special circumstances, I will not be calling it by default when I return all the pages. - We take our array of pages
and render them in
[slug].tsx
in the appropriate directory. Because the code in the slugs will be reused so often, it will be abstracted out intoapi/PageRender.ts
.- For
writing/all
, theAllPages
function will be called onposts/blog
,posts/essay
, andposts/tech
. The arrays will be joined and sorted by date. - To compile the pages in
pages
, theAllPages
function will be called as usual. But because the main pages in my website do not have dates, and we are not rendering a list of the main pages, we do not sort the dates automatically. We also render the pages inhome
in our top-level directory, because I like to also write my stuff in markdown.
- For
- We also render the list of pages
in
RenderPagesList.ts
. - Finally, we use
mdx-bundler
to convert pages into JSX and render them.