Git Product home page Git Product logo

mwskwong.com's Introduction

mwskwomg.com logo

mwskwong.com

Greetings ๐Ÿ‘‹.

Welcome to the source code of mwskwong.com. You can see how I created my site here.

PROD Deployment

  1. Create a PR from canary to main. Let the GitHub Actions run automatically.

  2. In Contentful

    1. Update the master alias target to the untargeted canary environment (check the Created date, it should be newer than the currently targeted environment).

    2. Delete the untargeted canary environment (i.e. the one previously targeted by master) and add a new one.

      • Environment ID naming: canary_YYYY-MM-DDTHH.mm.ss.SSSZ

        `canary_${new Date().toISOString().replaceAll(':', '.')}`;
      • Cloned from: development environment

    3. Update the Environments of the canary API key, check the newly added canary environment

  3. In Vercel, replace the value of environment variable CONTENTFUL_ENVIRONMENT of the Preview environment to the Contentful Environment ID defined in step 2.ii.

  4. Merge/enable auto merge for the PR.

Preview Deployment

  1. Create a PR to canary (optional)

  2. In Contentful

    1. Delete the latest canary environment and add a new one.

      • Environment ID naming: canary_YYYY-MM-DDTHH.mm.ss.SSSZ

        `canary_${new Date().toISOString().replaceAll(':', '.')}`;
      • Cloned from: development environment

    2. Update the Environments of the canary API key, check the newly added canary environment

  3. Perform step 3 of PROD Deployment

  4. Merge the PR or push code changes to canary directly

mwskwong.com's People

Contributors

mwskwong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mwskwong.com's Issues

Update `rehype-pretty-code`

It is currently incompatible with next-mdx-remote since the latter uses unified@10 (dependency of MDX 3) while the former uses unified@11.

The biggest benefit of upgarding rehype-pretty-code to v0.12.0+ is it has migrated to shikiji which no longer needs the shiki workaround when SSR and has better schematics.

Rewrite Senior Web Enginner job description

+ Enhanced viu.com's user login system and improved user profile section, amplifying user experience and engagement.
- Enhanced viu.com's user login system and improved user profile, improving user experience and engagement.
  • Website
  • CV
  • LinkedIn

Make use of partial prerendering to render `/blog` and `/blog/:slug`

Current

/blog and /blog/:slug are ISRed (revalidate for every hour). This is mostly for the sake of updating the view count periodically since the rest of the content is static.

To be explore

Partially render the two pages while wrapping the view count in Suspense, leaving it SSRed. This can potentially re-introduce like count, which is previously removed due to de-synchronized count between /blog and /blog/:slug.

unstable_noStore() may be helpful in this case since the counts are retrived using fetch internally.

Reference

Update CV

  • Update Geist font
  • Refine HA job titles (Only in CV, not website)
    1. Remove the team name from job titles
    2. Merge the two "Programmer"
  • Include HKJC job (after "probation")
    • CV
    • Contentful
  • Update MScISM completion date
    • CV
    • Contentful

Add like feature to blog

Using cookie as session ID:

// Like.tsx

const cookiesStore = cookies();
const liked = !cookiesStore.has('userId') ||
  await hasUserLikedBlog(blogId, cookiesStore.get('userId')?.value)

In LikeButton, optimistic update the liked status.

In server actions, assign userId if not exist. Should only be required in likeBlog, since people can't unlike it without liking it.

export const likeBlog = () => {
  const cookieStore = cookies();
  if (!cookieStore.has('userId')) {
    const userId = crypto.randomUUID();
    cookieStore.set('userId', userId, {
      httpOnly: true,
      secure: true,
      maxAge: 60 * 60 * 24 * 365,
      sameSite: 'strict',
    });
  }

  // prisma update
};

Implement circuit breaker for dynamic content

Context

Currently, some of the components are lazy loaded and depend on queries to Neon DB at runtime. When an unhandled/unexpected exception is thrown, e.g. the DB is unreachable, the error.tsx will take over, causing the entire site to be not functional. However, this doesn't have to be the case, since most of the contents are static and can be correctly displayed regardless of such failures

Proposal

  1. Implement a custom ErrorBoundary. Ref:
  2. Wrap all dynamic contents with ErrorBoundary, affected area
    1. /blog Views - fallback: -- views
    2. /blog/:slug Views - fallback: <eye_icon> -- views
    3. /guestbook SubmissionsList - fallback: null (or may be a nice looking logo like https://ant.design/components/empty)
    4. /guestbook JsonLd - fallback: null
  3. Bonus: create a server action, which sends email on error (in ErrorBoundary and error.tsx), with
    1. error
    2. errorInfo
    3. Parsed user agent with https://www.npmjs.com/package/ua-parser-js

New skill set UI

Motivation

The current UI isn't suitable where the content length of each category varies a lot.

Missing puzzles

  • Icon for each "skill"
    • Brands that don't have a monochrome icon
    • Non-branded skills? e.g. SEO

Hydration errors when using PPR

Show up when

  1. Directly accessing the PPR pages --> The error shows up after the delayed content is loading
  2. Client-side navigating to PPR pages --> The error shows up on the server side. This seems to cause significant delay on the navigation.

Make use of Sentry for monitoring

Migrate away from PlanetScale

PlanetScale is dropping its free tier.

Candidates:

  • Cloudflare D1
  • Neon

Also, need to update

  • Tech stack
  • Privacy Statement

Supabase --> Vercel integration

Poor Vercel integration

  • No by environment setting
    image

  • Disable SSL by default

  • Doesn't add pgbouncer=true by default to the Prisma connection string

Make use of animation

  1. Framer Motion?

  2. Will MUI Joy has animation integration similar to Material with React Transition Group?

Unreliable form error handling

Step to reproduce

  1. Fill in name, email, and subject
  2. Click submit --> expect focused on the message field
  3. Click submit again --> all fields are now showing error

[POC] Replace Zod with Valibot

Pros

  • Smaller bundle size
  • Has React Hook Form support (same as Zod)

Cons

[POC] Drop Formspree and self-implement form API + make use of EmailJS to send email

High-level Plan

  • Make use of PlanetScale to store the contact history

  • Make use of Server Actions to submit the form

    • Reuse formSchema for server-side validation.
  • Make use of @emailjs/nodejs to send email + auto reply.

Benefits

Performance in `/blog/:slug`

After changing the page from SSG to SSR, the TTFB is significantly impacted, I shall find a way to improve/workaround it.

Items to consider:

  • Make use of Cache-Control, ref.
  • Find the bottlenecks, is that due to API fetching or runtime rendering?
    • Seems to be caused by rendering.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.