Skip to content

Commit

Permalink
Merge pull request #207 from WestpacGEL/fix/gel-docs-contents
Browse files Browse the repository at this point in the history
Fix/gel docs contents
  • Loading branch information
samithaf authored Oct 26, 2023
2 parents 101542f + fce716f commit 8d540d7
Show file tree
Hide file tree
Showing 207 changed files with 48 additions and 43 deletions.
2 changes: 1 addition & 1 deletion apps/site/keystatic.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default config({
collections: {
designSystem: collection({
label: 'Design System',
path: 'src/content/design-system/**/',
path: 'src/content/design-system/*',
slugField: 'name',
schema: {
name: fields.slug({
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { formatComponentSlug } from '@/utils/format';

import { ArticlePage } from './components/article-page/article-page.component';

export function generateMetadata({ params }: { params: { article: string } }) {
const { article } = params;
return { title: formatComponentSlug(article[article.length - 1]) };
export function generateMetadata({ params }: { params: { slug: string } }) {
const { slug } = params;
return { title: formatComponentSlug(slug) };
}

export default async function ArticleServerPage({ params }: { params: { article: string } }) {
const { article: articleParam } = params;
const article = await reader.collections.articles.readOrThrow(articleParam);
export default async function ArticleServerPage({ params }: { params: { slug: string } }) {
const { slug } = params;
const article = await reader.collections.articles.readOrThrow(slug);

const [articleContent, author] = await Promise.all([
article.content(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { HamburgerMenuIcon } from '@westpac/ui/icon';
import { useParams, useSearchParams } from 'next/navigation';
import React, { useEffect, useState } from 'react';

import { useSidebar } from '@/app/design-system/my-components';
import { BrandKey } from '@/app/types/brand.types';
import { formatComponentSlug } from '@/utils/format';

import { useSidebar } from '../../../components/sidebar/sidebar.context';

import { styles as headerStyles } from './header.styles';

const FIXED_HEADER = 162; // 228 - 66 = height to stick
Expand All @@ -18,7 +17,7 @@ export function Header({ className }: { className?: string }) {
const searchParams = useSearchParams();
const brand = searchParams.get('brand')?.toLowerCase();
const params = useParams();
const component = formatComponentSlug(params?.component.at(-1) ?? '');
const component = formatComponentSlug(params?.slug.toString() || '');
const styles = headerStyles({ brand: brand as BrandKey, fixed, className });
const { setOpen } = useSidebar();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import { ContentTabs } from './components';
import { AccessibilitySectionProps } from './components/content-tabs/components/accessibility-content/accessibility-content.types';
import { DesignSectionProps } from './components/content-tabs/components/design-content/design-content.types';

export function generateMetadata({ params }: { params: { component: string } }) {
const { component } = params;
return { title: formatComponentSlug(component[component.length - 1]) };
export function generateMetadata({ params }: { params: { slug: string } }) {
const { slug } = params;
return { title: formatComponentSlug(slug) };
}

export default async function ComponentPage({ params }: { params: { component: string[] } }) {
const { component } = params;
export default async function ComponentPage({ params }: { params: { slug: string } }) {
const { slug } = params;
const [content, westpacInfo] = await Promise.all([
reader.collections.designSystem.readOrThrow(component.join('/')),
reader.collections.designSystem.readOrThrow(slug),
reader.singletons.westpacUIInfo.readOrThrow(),
]);
const componentName = component[1]
const componentName = slug
.split('-')
.map(name => `${name[0].toUpperCase()}${name.slice(1)}`)
.join('');
Expand Down
2 changes: 1 addition & 1 deletion apps/site/src/app/design-system/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { reader } from '@/app/reader';
import { formatNavItems } from '@/utils/format';

import { Sidebar, SidebarContextProvider } from './components';
import { Sidebar, SidebarContextProvider } from './my-components';

export default async function DesignSystemLayout({ children }: { children: React.ReactNode }) {
const items = await reader.collections.designSystem.list();
Expand Down
2 changes: 1 addition & 1 deletion apps/site/src/app/design-system/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
TwitterLogo,
} from '@/components/logos';

import { Hero, Section, SectionHeading, SectionItem } from './components';
import { Hero, Section, SectionHeading, SectionItem } from './my-components';

export default function DesignSystemHomePage() {
return (
Expand Down
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/breadcrumb/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Breadcrumb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Button-Dropdown
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: button-group
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/button/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Button
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: checkbox-group
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/collapsible/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Collapsible
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/colors/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Colors
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/date-picker/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Date-Picker
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/flexi-cell/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Flexi-Cell
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/icon/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Icons
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/input-field/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Input-Field
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/input/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Input
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/link/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Link
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/list/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: List
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/modal/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Modal
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/panel/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Panel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Progress-Bar
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Progress-Rope
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/radio-group/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: radio-group
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/select/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Select
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/switch/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Switch
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/table/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Table
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/tabs/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Tabs
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/textarea/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Textarea
1 change: 1 addition & 0 deletions apps/site/src/content/design-system/typography/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: Typography
29 changes: 5 additions & 24 deletions apps/site/src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,10 @@ export function formatComponentSlug(component: string) {
}

export function formatNavItems(navList: string[]) {
const navItems: any[] = [];
navList.forEach(path => {
const params = path.split('/');
let curr = navItems;
params.forEach((param, i) => {
if (i === params.length - 1) {
curr.push({ label: param, path });
} else {
let exists = false;
curr.forEach(item => {
if (item.label === param) {
exists = true;
curr = item.children;
}
});

if (!exists) {
const newNode = { label: param, children: [] };
curr.push(newNode);
curr = newNode.children;
}
}
});
return navList.map(component => {
return {
label: component,
path: `components/${component}`,
};
});
return navItems;
}

0 comments on commit 8d540d7

Please sign in to comment.