GitHub Project Task: Configurable Navbar and Footer
Task Description
Make the website's navigation bar and footer configurable so that users can select a navbar or footer type to use for their website. These components will not be included in the content generators but will function as standalone configurable elements within the layout system.
Checklist
1. Inspect Flexiwind Components
2. Convert Components
3. Add Configurable Support
4. Restrict Page Listings
5. Add to Configuration Map
6. Create Layout Artifacts
Code Examples
Example: Navbar Component
import React from 'react';
export const SimpleNavbar = ({ theme, pages }) => {
return (
<nav className={`bg-${theme?.colors?.background || 'white'} shadow-md`}>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex justify-between h-16">
<div className="flex">
<a href="/" className={`text-${theme?.colors?.primaryText || 'blue-700'} font-bold`}>
Brand
</a>
</div>
<div className="flex space-x-4">
{pages?.map((page, index) => (
<a
key={index}
href={page.path}
className={`text-${theme?.colors?.secondaryText || 'gray-600'} hover:text-${theme?.colors?.hover || 'gray-800'}`}
>
{page.name}
</a>
))}
</div>
</div>
</div>
</nav>
);
};
Mapping Components
In src/components/layout/navbars/index.js:
import { SimpleNavbar } from './SimpleNavbar';
// Add other navbars as needed
export const headers = {
SimpleNavbar,
// Add other navbar components
};
In src/components/layout/footers/index.js:
import { SimpleFooter } from './SimpleFooter';
// Add other footers as needed
export const footers = {
SimpleFooter,
// Add other footer components
};
Modify Layout Component
In src/components/layout/Layout.js:
import { useSiteConfig } from '@/hooks/useSiteConfig';
import { headers } from './navbars';
import { footers } from './footers';
export const Layout = ({ children }) => {
const config = useSiteConfig();
const Header = headers[config.selectedHeader];
const Footer = footers[config.selectedFooter];
return (
<>
{Header && <Header theme={config.theme} pages={config.pages} />}
<main>{children}</main>
{Footer && <Footer theme={config.theme} pages={config.pages} />}
</>
);
};
Demo Configuration in layout-artifacts.js
import React from 'react';
import { Layout } from '@/components/layout/Layout';
const demoConfig = {
selectedHeader: 'SimpleNavbar',
selectedFooter: 'SimpleFooter',
theme: {
colors: {
background: 'gray-50',
primaryText: 'blue-700',
secondaryText: 'gray-500',
hover: 'blue-900',
},
},
pages: [
{ name: 'Home', path: '/' },
{ name: 'About', path: '/about' },
{ name: 'Contact', path: '/contact' },
],
};
const LayoutArtifacts = () => {
return (
<Layout {...demoConfig}>
<h1 className="text-center">Layout Artifacts Demo</h1>
</Layout>
);
};
export default LayoutArtifacts;
Expected Deliverables
- Navbar and footer React components in
src/components/layout/navbars and src/components/layout/footers.
- Updated
Layout component to dynamically render headers and footers based on the configuration.
- Configurable
headers and footers maps in respective index.js files.
- A new
layout-artifacts.js page demonstrating the dynamic rendering.
Let me know if you have additional requirements or need further clarification!
GitHub Project Task: Configurable Navbar and Footer
Task Description
Make the website's navigation bar and footer configurable so that users can select a navbar or footer type to use for their website. These components will not be included in the content generators but will function as standalone configurable elements within the layout system.
Checklist
1. Inspect Flexiwind Components
2. Convert Components
src/components/layout/navbarssrc/components/layout/footers3. Add Configurable Support
Layoutcomponent to:useSiteConfighook to load the site configuration.config.selectedHeader) and footer (config.selectedFooter) based on aheadersandfootersmap.4. Restrict Page Listings
pagesconfiguration.pagesexist in the configuration.5. Add to Configuration Map
headersmap insrc/components/layout/navbars/index.jsfootersmap insrc/components/layout/footers/index.js6. Create Layout Artifacts
src/pages/layout-artifacts.jsto demonstrate the configurable navbar and footer components.Code Examples
Example: Navbar Component
Mapping Components
In
src/components/layout/navbars/index.js:In
src/components/layout/footers/index.js:Modify Layout Component
In
src/components/layout/Layout.js:Demo Configuration in
layout-artifacts.jsExpected Deliverables
src/components/layout/navbarsandsrc/components/layout/footers.Layoutcomponent to dynamically render headers and footers based on the configuration.headersandfootersmaps in respectiveindex.jsfiles.layout-artifacts.jspage demonstrating the dynamic rendering.Let me know if you have additional requirements or need further clarification!