Package Exports
- @infinum/docusaurus-theme
- @infinum/docusaurus-theme/dist/infinum-docusaurus-theme.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@infinum/docusaurus-theme) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Infinum Docusaurus theme
Note This repo is still work in progress. Code might not be optimal, documentation might not be complete. Not all Docusaurus features have been restyled yet!
This theme adds style overrides and new components for building consistent open-source, Docusaurus-based project pages.
To get started (WIP)
Create a new Docusaurus project (with the
classictheme!):npx create-docusaurus@latest my-website classicInstall the Infinum Docusaurus theme package:
npm i @infinum/docusaurus-themeConfigure Docusaurus:
- Open the config file (
docusaurus.config.js) - Edit your
title,tagline, andfavicon - Edit the navbar:
- Remove
titlefrom thenavbarobject - Set the
logoand the menuitems(avoid multi-level nesting if possible)
- Remove
- Edit the footer
Note: look for thefooter: { links: [ { title: 'Community', items: [ { label: '', href: 'https://...', icon: '', }, ... ], }, ], }iconin the Icon component from the package (will also include a list at some point) - Edit the
copyright - At the top of the file add:
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
- Add these at the end of the config, just after
copyright:prism: { theme: darkCodeTheme, }, colorMode: { defaultMode: 'light', disableSwitch: true, respectPrefersColorScheme: false, },
- Open the config file (
Override some of the default components
- Replace the footer
- Run
npm run swizzle @docusaurus/theme-classic Footer -- --eject - Go to
src/theme/Footerand remove everything exceptindex.js - Replace the contents of
index.jswith:import React from 'react'; import { useThemeConfig } from '@docusaurus/theme-common'; import { Footer as InfinumFooter } from '@infinum/docusaurus-theme'; function Footer() { const { footer } = useThemeConfig(); return ( <InfinumFooter footer={footer} /> ); } export default React.memo(Footer);
- Run
- Replace the contents of the blog listing page
- Run
npm run swizzle @docusaurus/theme-classic BlogListPage -- --eject - Go to
src/theme/BlogListPageand remove everything exceptindex.js - Replace the contents fo
index.jswith:(make sure to replace any of the generic content here, like the IconLinkCards)import React from 'react'; import clsx from 'clsx'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import { PageMetadata, HtmlClassNameProvider, ThemeClassNames, } from '@docusaurus/theme-common'; import BlogLayout from '@theme/BlogLayout'; import BlogListPaginator from '@theme/BlogListPaginator'; import SearchMetadata from '@theme/SearchMetadata'; import BlogPostItems from '@theme/BlogPostItems'; import { IconLinkCards, CtaImageButton, icons } from '@infinum/docusaurus-theme'; function BlogListPageMetadata(props) { const { metadata } = props; const { siteConfig: { title: siteTitle }, } = useDocusaurusContext(); const { blogDescription, blogTitle, permalink } = metadata; const isBlogOnlyMode = permalink === '/'; const title = isBlogOnlyMode ? siteTitle : blogTitle; return ( <> <PageMetadata title={title} description={blogDescription} /> <SearchMetadata tag="blog_posts_list" /> </> ); } function BlogListPageContent(props) { const { metadata, items } = props; return ( <BlogLayout> <h1 className='es-big-title'>Typing as we code</h1> <div className='es-blog-grid'> <BlogPostItems items={items} /> </div> <BlogListPaginator metadata={metadata} /> <IconLinkCards gray title='Start exploring' cards={[ { icon: icons.wordpress, text: 'Eightshift Boilerplate', url: '/blog' }, { icon: icons.lockPrivacySecurity, text: 'Eightshift Coding Standards for WordPress', url: '/blog' }, { icon: icons.userJourney, text: 'Eightshift Boilerplate Plugin', url: '/blog' }, { icon: icons.book, text: 'Eightshift Libs', url: '/blog' }, { icon: icons.frontendDevelopment, text: 'Eightshift Frontend Libs', url: '/blog' }, { icon: icons.designerPenTool, text: 'Eightshift Forms', url: '/blog' }, { icon: icons.book2, text: 'Eightshift Docs', url: '/blog' }, { icon: icons.book, text: 'Eightshift Storybook', url: '/blog' } ]} /> <CtaImageButton gray title='Find more libraries, tools, and design assets free for everyone to use.' buttonLabel='Open-source freebies' buttonUrl='/blog' imageUrl='/img/wp4.png' /> </BlogLayout> ); } export default function BlogListPage(props) { return ( <HtmlClassNameProvider className={clsx( ThemeClassNames.wrapper.blogPages, ThemeClassNames.page.blogListPage, )}> <BlogListPageMetadata {...props} /> <BlogListPageContent {...props} /> </HtmlClassNameProvider> ); }
- Run
- Replace the footer
Build your site
npm startand check everything