Socket
Socket
Sign inDemoInstall

@docusaurus/theme-common

Package Overview
Dependencies
Maintainers
4
Versions
1700
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docusaurus/theme-common

Common code for Docusaurus themes.


Version published
Weekly downloads
286K
increased by11.41%
Maintainers
4
Weekly downloads
 
Created

Package description

What is @docusaurus/theme-common?

@docusaurus/theme-common is a package that provides common utilities and components for building themes in Docusaurus, a popular static site generator. It includes shared components, hooks, and utilities that can be used to create custom themes or extend existing ones.

What are @docusaurus/theme-common's main functionalities?

useThemeConfig

The `useThemeConfig` hook allows you to access the theme configuration in your components. This is useful for customizing the appearance and behavior of your site based on the theme settings.

import { useThemeConfig } from '@docusaurus/theme-common';

const MyComponent = () => {
  const themeConfig = useThemeConfig();
  return <div>{JSON.stringify(themeConfig)}</div>;
};

useColorMode

The `useColorMode` hook provides access to the current color mode (light or dark) and a function to toggle it. This is useful for implementing dark mode support in your custom themes.

import { useColorMode } from '@docusaurus/theme-common';

const MyComponent = () => {
  const { colorMode, setColorMode } = useColorMode();
  return (
    <div>
      <p>Current color mode: {colorMode}</p>
      <button onClick={() => setColorMode(colorMode === 'dark' ? 'light' : 'dark')}>Toggle Color Mode</button>
    </div>
  );
};

useWindowSize

The `useWindowSize` hook provides the current window size, which can be useful for responsive design and adapting your components based on the viewport dimensions.

import { useWindowSize } from '@docusaurus/theme-common';

const MyComponent = () => {
  const windowSize = useWindowSize();
  return <div>Window size: {windowSize.width} x {windowSize.height}</div>;
};

Other packages similar to @docusaurus/theme-common

Changelog

Source

2.4.3 (2023-09-20)

:bug: Bug Fix
  • docusaurus-plugin-content-docs
    • #9107 fix(content-docs): sidebar generator should return customProps for doc items (@TheCatLady)
  • docusaurus-theme-classic
    • #9108 feat(theme-classic): add description & keywords microdata to blog posts (@TheCatLady)
    • #9099 fix(theme): only set classname on ul elements if they have an existing class (@homotechsual)
    • #9243 fix(theme-common): ThemedComponent should display something when JS is disabled (@slorber)
  • docusaurus-theme-classic, docusaurus-theme-common
    • #9130 fix(theme): canonical url should be not change after hydration if url accessed with/without trailing slash (@ori-shalom)
Committers: 4

Readme

Source

@docusaurus/theme-common

Common code for Docusaurus themes.

FAQs

Package last updated on 20 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc