liyaodong / nextjs-demo

Nextjs demo with multiple subdomain and color schema

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nextjs antdesign dynamic theme demo

Live example

Default: nextjs.liyaodong.com

Dark: darknextjs.liyaodong.com

Red: rednextjs.liyaodong.com

How to customize

Refer to pages/index.tsx #getThemeFromHostName function

function getThemeFromHostName(context) {
  let theme = 'default';

  // only run on client side
  if (!process.browser) {
    return theme;
  }

  // can be an api call as well
  if (/dark/i.test(window.location.hostname)) {
    theme = 'dark';
  }

  if (/red/i.test(window.location.hostname)) {
    theme = { '@primary-color': '#ff0000' };
  }

  return theme;
}

Major plugin used

next-dynamic-antd-theme

About

Nextjs demo with multiple subdomain and color schema


Languages

Language:TypeScript 71.4%Language:JavaScript 24.6%Language:Less 3.9%