Skip to content

Commit

Permalink
feat: inject logos collective footer links into theme config
Browse files Browse the repository at this point in the history
  • Loading branch information
jeangovil committed May 31, 2023
1 parent 889e563 commit 75f76a8
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 78 deletions.
65 changes: 0 additions & 65 deletions packages/docusaurus-playground/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,71 +119,6 @@ const config = {
},
],
},
{
title: 'Research',
items: [
{
href: '/',
label: 'VacP2P',
},
{
href: '/',
label: 'AFAIK',
},
],
},
{
title: 'Infrastructure',
items: [
{
href: '/',
label: 'Waku',
},
{
href: '/',
label: 'Nimbus',
},
{
href: '/',
label: 'Codex',
},
{
href: '/',
label: 'Nomos',
},
],
},
{
title: 'Creative Studio',
items: [
{
href: '/',
label: 'Acid.info',
},
],
},
{
title: 'Movement',
items: [
{
href: '/',
label: 'Logos',
},
],
},
{
title: 'User-facing products',
items: [
{
href: '/',
label: 'Status',
},
{
href: '/',
label: 'Keycard',
},
],
},
],
},
}),
Expand Down
5 changes: 2 additions & 3 deletions packages/logos-docusaurus-preset/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ export default function logosPreset(
path.join(__dirname, '../static', options.businessUnit),
]

siteConfig.themeConfig = defaultsDeep(
[{}, context.siteConfig.themeConfig, themeConfigs[options.businessUnit]],
false,
siteConfig.themeConfig = themeConfigs[options.businessUnit](
context.siteConfig.themeConfig,
)

Object.entries(siteConfig).forEach(
Expand Down
68 changes: 67 additions & 1 deletion packages/logos-docusaurus-preset/src/theme-config/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,73 @@ export const baseThemeConfig: ThemeConfig = {
},
footer: {
logo: {},
links: [],
links: [
{
title: 'shared:Research',
items: [
{
href: 'https://vac.dev',
label: 'VacP2P',
},
{
href: 'https://afaik.institute',
label: 'AFAIK',
},
],
},
{
title: 'shared:Infrastructure',
items: [
{
href: 'https://waku.org/',
label: 'Waku',
},
{
href: 'https://nimbus.team/',
label: 'Nimbus',
},
{
href: 'https://codex.storage',
label: 'Codex',
},
{
href: '#',
label: 'Nomos',
},
],
},
{
title: 'shared:Creative Studio',
items: [
{
href: 'https://acid.info',
label: 'Acid.info',
},
],
},
{
title: 'shared:Movement',
items: [
{
href: 'https://logos.co',
label: 'Logos',
},
],
},
{
title: 'shared:User-facing products',
items: [
{
href: 'https://status.im',
label: 'Status',
},
{
href: 'https://keycard.tech',
label: 'Keycard',
},
],
},
],
copyright: `Logos, ${new Date().getFullYear()}`,
},
prism: {
Expand Down
31 changes: 26 additions & 5 deletions packages/logos-docusaurus-preset/src/theme-config/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
import { ThemeConfig } from '@docusaurus/types'
import { ThemeConfig } from '@docusaurus/preset-classic'
import { BusinessUnits } from '../types'
import { defaultsDeep } from '../utils/object.utils'
import baseThemeConfig from './base'
import codexThemeConfig from './codex'
import logosThemeConfig from './logos'
import wakuThemeConfig from './waku'

export const themeConfigs: Record<BusinessUnits, ThemeConfig> = {
[BusinessUnits.Logos]: logosThemeConfig,
[BusinessUnits.Codex]: codexThemeConfig,
[BusinessUnits.Waku]: wakuThemeConfig,
const merge =
(base: ThemeConfig) =>
(config: ThemeConfig): ThemeConfig => {
const merged: ThemeConfig = {
...(defaultsDeep([{}, config, base], false) as ThemeConfig),
}

return {
...merged,
footer: {
...merged.footer,
links: [
...(merged.footer?.links ?? []),
...(baseThemeConfig.footer?.links ?? []),
],
},
}
}

export const themeConfigs: Record<BusinessUnits, ReturnType<typeof merge>> = {
[BusinessUnits.Logos]: merge(logosThemeConfig),
[BusinessUnits.Codex]: merge(codexThemeConfig),
[BusinessUnits.Waku]: merge(wakuThemeConfig),
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
import React from 'react'
import { Button } from '@acid-info/lsd-react'
import { MultiColumnFooter, SimpleFooter } from '@docusaurus/theme-common'
import clsx from 'clsx'
import React from 'react'
import styles from './styles.module.scss'
import { Button } from '@acid-info/lsd-react'

const groupLinks = (
links: MultiColumnFooter['links'] | SimpleFooter['links'],
) => {
const siteLinks: any[] = []
const sharedLinks: any[] = []

for (const link of links) {
if (
'title' in link &&
typeof link.title === 'string' &&
link.title.startsWith('shared:')
) {
sharedLinks.push({ ...link, title: link.title.slice(7) })
} else siteLinks.push(link)
}

return [siteLinks, sharedLinks]
}

export default function FooterLayout({ style, links, logo, copyright }) {
const firstRow = [...links.props.links.slice(0, 2)]
const secondRow = [...links.props.links.slice(2)]
const [firstRow, secondRow] = groupLinks(links.props.links)

const handleScrollToTop = () => {
window.scrollTo({
Expand Down

0 comments on commit 75f76a8

Please sign in to comment.