From a774c9a346b1ab81580679fd849686a5e3736436 Mon Sep 17 00:00:00 2001
From: Joe Fusco
@@ -61,7 +67,7 @@ const FeatureTabsLeft = (layout) => {
'font-display text-lg [&:not(:focus-visible)]:focus:outline-none',
selectedIndex === featureIndex
? 'text-white dark:text-slate-200 hover:text-white group-hover:text-white dark:hover:text-slate-300 lg:dark:hover:text-slate-200'
- : 'text-slate-800 hover:text-white group-hover:text-white dark:hover:text-slate-200'
+ : 'text-slate-800 hover:text-white group-hover:text-white dark:hover:text-slate-200',
)}
>
@@ -73,7 +79,7 @@ const FeatureTabsLeft = (layout) => {
'mt-2 hidden text-sm lg:block group-hover:text-white dark:group-hover:text-slate-200',
selectedIndex === featureIndex
? 'text-slate-800 lg:text-white dark:text-slate-200'
- : 'text-slate-800'
+ : 'text-slate-800',
)}
>
{feature.featureDescription}
@@ -92,15 +98,23 @@ const FeatureTabsLeft = (layout) => {
{feature.name}
-{feature.featureDescription}
++ {feature.featureDescription} +
{JSON.stringify(data, null, 2)}; - } - + if (!contentNodes.nodes || !contentNodes.nodes.length) { + return
{JSON.stringify(data, null, 2)}+ } return ( -
- WPGraphQL for ACF exposes ACF Fields to the GraphQL Schema allowing you to query for the data managed by ACF. -
-- Below you will find a list of the Field Types that are supported by WPGraphQL for ACF and documentation for how to query for them. -
-+ WPGraphQL for ACF exposes ACF Fields to the GraphQL Schema allowing + you to query for the data managed by ACF. +
++ Below you will find a list of the Field Types that are supported by + WPGraphQL for ACF and documentation for how to query for them. +
+@@ -126,22 +134,22 @@ const ACFE_AdvancedLink = gql` } } } -`; +` HomepageLayoutsLayoutsHero.fragment = gql` -fragment HomepageLayoutsLayoutsHero on LayoutHero_Fields { - title - description - getStartedLink { - ...AcfeAdvancedLink - } - githubLink { - ...AcfeAdvancedLink + fragment HomepageLayoutsLayoutsHero on LayoutHero_Fields { + title + description + getStartedLink { + ...AcfeAdvancedLink + } + githubLink { + ...AcfeAdvancedLink + } + codeSample + codeFileName } - codeSample - codeFileName -} -${ACFE_AdvancedLink} -`; + ${ACFE_AdvancedLink} +` -export default HomepageLayoutsLayoutsHero; \ No newline at end of file +export default HomepageLayoutsLayoutsHero diff --git a/components/HomepageLayoutsLayoutsSupportedFieldTypes.jsx b/components/HomepageLayoutsLayoutsSupportedFieldTypes.jsx index 024a289..04d4dc2 100644 --- a/components/HomepageLayoutsLayoutsSupportedFieldTypes.jsx +++ b/components/HomepageLayoutsLayoutsSupportedFieldTypes.jsx @@ -1,8 +1,6 @@ import { useEffect, useMemo, useRef, useState } from 'react' import clsx from 'clsx' -import { - useInView, -} from 'framer-motion' +import { useInView } from 'framer-motion' import Link from 'next/link' import { Container } from '@/components/Container' @@ -21,30 +19,25 @@ function FieldType({ title, uri, featuredImage, className, ...props }) { ) } @@ -90,7 +83,6 @@ function FieldTypeColumn({ style={{ '--marquee-duration': duration }} > {fieldTypes.concat(fieldTypes).map((fieldType, fieldTypeIndex) => ( -= fieldTypes.length} @@ -103,13 +95,13 @@ function FieldTypeColumn({ } function FieldTypeGrid({ fieldTypes }) { - let containerRef = useRef() let isInView = useInView(containerRef, { once: true, amount: 0.4 }) - let columns = fieldTypes && fieldTypes.length > 0 ? splitArray(fieldTypes, 3) : null; + let columns = + fieldTypes && fieldTypes.length > 0 ? splitArray(fieldTypes, 3) : null - if ( ! columns) { - return null; + if (!columns) { + return null } columns = [columns[0], columns[1], splitArray(columns[2], 2)] @@ -127,7 +119,7 @@ function FieldTypeGrid({ fieldTypes }) { clsx( reviewIndex >= columns[0].length + columns[2][0].length && 'md:hidden', - reviewIndex >= columns[0].length && 'lg:hidden' + reviewIndex >= columns[0].length && 'lg:hidden', ) } msPerPixel={10} @@ -153,7 +145,7 @@ function FieldTypeGrid({ fieldTypes }) { ) } -const HomepageLayoutsLayoutsSupportedFieldTypes = ( data ) => { +const HomepageLayoutsLayoutsSupportedFieldTypes = (data) => { return ( { id="reviews-title" className="text-3xl font-medium tracking-tight mb-5 dark:text-gray-100 text-gray-900 sm:text-center" > - { data.title } + {data.title} - + @@ -179,7 +174,7 @@ HomepageLayoutsLayoutsSupportedFieldTypes.fragment = gql` fragment HomepageLayoutsLayoutsSupportedFieldTypes on LayoutSupportedFieldTypes_Fields { title description - fieldTypes(first:100) { + fieldTypes(first: 100) { nodes { __typename ... on FieldType { @@ -198,4 +193,4 @@ HomepageLayoutsLayoutsSupportedFieldTypes.fragment = gql` } ` -export default HomepageLayoutsLayoutsSupportedFieldTypes; +export default HomepageLayoutsLayoutsSupportedFieldTypes diff --git a/components/Layout.jsx b/components/Layout.jsx index 3871449..0263ebc 100644 --- a/components/Layout.jsx +++ b/components/Layout.jsx @@ -2,7 +2,10 @@ import { useCallback, useEffect, useState } from 'react' import Link from 'next/link' import clsx from 'clsx' -import { SidebarNavigation, SidebarNavigationFragment } from '@/components/SidebarNavigation' +import { + SidebarNavigation, + SidebarNavigationFragment, +} from '@/components/SidebarNavigation' import { Prose } from '@/components/Prose' import { gql } from '@apollo/client' import { flatListToHierarchical } from '@faustwp/core' @@ -20,8 +23,7 @@ function useTableOfContents(tableOfContents) { let [currentSection, setCurrentSection] = useState(tableOfContents?.[0]?.id) let getHeadings = useCallback((tableOfContents) => { - - if ( ! tableOfContents.length ) return [] + if (!tableOfContents.length) return [] return tableOfContents .flatMap((node) => [node.id, ...node.children.map((child) => child.id)]) @@ -43,9 +45,10 @@ function useTableOfContents(tableOfContents) { function onScroll() { let top = window.scrollY - if ( ! headings || ! headings.length ) return; + if (!headings || !headings.length) return - let current = headings && headings.length > 0 ? headings[0]?.id ?? null : null; + let current = + headings && headings.length > 0 ? headings[0]?.id ?? null : null for (let heading of headings) { if (top >= heading?.top) { current = heading.id @@ -66,27 +69,25 @@ function useTableOfContents(tableOfContents) { } export function Layout({ data, children, toc, title }) { - - let tableOfContents = toc && toc.length - ? collectHeadings( toc ) + let tableOfContents = toc && toc.length ? collectHeadings(toc) : [] + + const menuItems = data?.menuItems ?? [] + const navigation = menuItems?.nodes + ? flatListToHierarchical(menuItems.nodes, { + idKey: 'id', + childrenKey: 'links', + parentKey: 'parentId', + }) : [] - - const menuItems = data?.menuItems ?? []; - const navigation = menuItems?.nodes ? flatListToHierarchical( menuItems.nodes, { - idKey: 'id', - childrenKey: 'links', - parentKey: 'parentId' - } ) : []; let allLinks = navigation?.flatMap((section) => section.links) ?? [] let linkIndex = allLinks.findIndex((link) => { return link.href === data?.node?.uri }) let previousPage = allLinks[linkIndex - 1] - let nextPage = allLinks[linkIndex + 1] let section = allLinks.find((section) => - section.links.find((link) => link.href === data?.node?.uri) + section.links.find((link) => link.href === data?.node?.uri), ) let currentSection = useTableOfContents(tableOfContents) @@ -104,7 +105,7 @@ export function Layout({ data, children, toc, title }) { <> - +@@ -183,7 +184,7 @@ export function Layout({ data, children, toc, title }) { className={clsx( isActive(section) ? 'text-sky-500' - : 'font-normal text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-300' + : 'font-normal text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-300', )} > {section.title} diff --git a/components/LayoutArchive.jsx b/components/LayoutArchive.jsx index a0f5a5e..49597d4 100644 --- a/components/LayoutArchive.jsx +++ b/components/LayoutArchive.jsx @@ -1,4 +1,7 @@ -import { SidebarNavigation, SidebarNavigationFragment } from '@/components/SidebarNavigation' +import { + SidebarNavigation, + SidebarNavigationFragment, +} from '@/components/SidebarNavigation' import { Prose } from '@/components/Prose' import { gql } from '@apollo/client' import { flatListToHierarchical } from '@faustwp/core' @@ -12,30 +15,32 @@ export const LayoutFragment = gql` ` export function LayoutArchive({ data, children, title }) { - const menuItems = data?.menuItems ?? []; - const navigation = menuItems?.nodes ? flatListToHierarchical( menuItems.nodes, { - idKey: 'id', - childrenKey: 'links', - parentKey: 'parentId' - } ) : []; + const menuItems = data?.menuItems ?? [] + const navigation = menuItems?.nodes + ? flatListToHierarchical(menuItems.nodes, { + idKey: 'id', + childrenKey: 'links', + parentKey: 'parentId', + }) + : [] let allLinks = navigation?.flatMap((section) => section.links) ?? [] let section = allLinks.find((section) => - section.links.find((link) => link.href === data?.node?.uri) + section.links.find((link) => link.href === data?.node?.uri), ) return ( <>- -diff --git a/components/TopNavigation.jsx b/components/TopNavigation.jsx index 07b9b0a..29c11d6 100644 --- a/components/TopNavigation.jsx +++ b/components/TopNavigation.jsx @@ -1,10 +1,10 @@ -"use client"; +'use client' -import * as React from "react" -import Link from "next/link" -import { gql } from "@apollo/client"; +import * as React from 'react' +import Link from 'next/link' +import { gql } from '@apollo/client' -import { cn } from "@/lib/utils" +import { cn } from '@/lib/utils' import { NavigationMenu, NavigationMenuContent, @@ -13,11 +13,11 @@ import { NavigationMenuList, NavigationMenuTrigger, navigationMenuTriggerStyle, -} from "@/components/ui/navigation-menu" +} from '@/components/ui/navigation-menu' export const TopNavigationFragment = gql` fragment TopNavigationFragment on RootQuery { - menuItems(first: 100 where: { location: TOP }) { + menuItems(first: 100, where: { location: TOP }) { nodes { id label @@ -32,19 +32,21 @@ export const TopNavigationFragment = gql` } } } -`; +` export function TopNavigation({ navigation }) { return (- - - ----- +> ) } diff --git a/components/LayoutFrontPage.jsx b/components/LayoutFrontPage.jsx index e736e53..983d28b 100644 --- a/components/LayoutFrontPage.jsx +++ b/components/LayoutFrontPage.jsx @@ -1,9 +1,6 @@ -import { useCallback, useEffect, useState } from 'react' - import { TopNavigationFragment } from '@/components/TopNavigation' import { gql } from '@apollo/client' import { flatListToHierarchical } from '@faustwp/core' -import { collectHeadings } from '@/lib/utils' import { SiteHeader } from '@/components/SiteHeader' export const LayoutFragment = gql` @@ -14,18 +11,18 @@ export const LayoutFragment = gql` ` export function LayoutFrontPage({ data, children }) { - const menuItems = data?.menuItems ?? []; - const navigation = menuItems?.nodes ? flatListToHierarchical( menuItems.nodes, { - idKey: 'id', - childrenKey: 'links', - parentKey: 'parentId' - } ) : []; + const menuItems = data?.menuItems ?? [] + const navigation = menuItems?.nodes + ? flatListToHierarchical(menuItems.nodes, { + idKey: 'id', + childrenKey: 'links', + parentKey: 'parentId', + }) + : [] return ( <>+++ + + +++++ {(title || section) && ( -@@ -53,8 +58,8 @@ export function LayoutArchive({ data, children, title }) { )} {children} - <> - {children} - > + <>{children}> > ) } diff --git a/components/Logo.jsx b/components/Logo.jsx index 9fc18ce..a6c9d6d 100644 --- a/components/Logo.jsx +++ b/components/Logo.jsx @@ -1,4 +1,4 @@ -import Image from "next/image" +import Image from 'next/image' function LogomarkPaths() { return ( @@ -20,11 +20,11 @@ export function Logomark(props) { export function Logo(props) { return ( ) } diff --git a/components/Prose.jsx b/components/Prose.jsx index e3ce6dc..e185754 100644 --- a/components/Prose.jsx +++ b/components/Prose.jsx @@ -17,7 +17,7 @@ export function Prose({ as: Component = 'div', className, ...props }) { // pre 'prose-pre:rounded-xl prose-pre:bg-slate-900 prose-pre:shadow-lg dark:prose-pre:bg-slate-800/60 dark:prose-pre:shadow-none dark:prose-pre:ring-1 dark:prose-pre:ring-slate-300/10', // hr - 'dark:prose-hr:border-slate-800' + 'dark:prose-hr:border-slate-800', )} {...props} /> diff --git a/components/Search.jsx b/components/Search.jsx index d0da796..a9427e2 100644 --- a/components/Search.jsx +++ b/components/Search.jsx @@ -48,7 +48,7 @@ function useAutocomplete() { ] }) }, - }) + }), ) return { autocomplete, autocompleteState } @@ -98,7 +98,7 @@ function SearchResult({ result, autocomplete, collection, query }) { let id = useId() let sectionTitle = navigation.find((section) => - section.links.find((link) => link.href === result.url.split('#')[0]) + section.links.find((link) => link.href === result.url.split('#')[0]), )?.title let hierarchy = [sectionTitle, result.pageTitle].filter(Boolean) @@ -174,7 +174,7 @@ function SearchResults({ autocomplete, query, collection }) { const SearchInput = forwardRef(function SearchInput( { autocomplete, autocompleteState, onClose }, - inputRef + inputRef, ) { let inputProps = autocomplete.getInputProps({}) @@ -185,7 +185,7 @@ const SearchInput = forwardRef(function SearchInput( ref={inputRef} className={clsx( 'flex-auto appearance-none bg-transparent pl-12 text-slate-900 outline-none placeholder:text-slate-400 focus:w-full focus:flex-none dark:text-white sm:text-sm [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden [&::-webkit-search-results-button]:hidden [&::-webkit-search-results-decoration]:hidden', - autocompleteState.status === 'stalled' ? 'pr-11' : 'pr-4' + autocompleteState.status === 'stalled' ? 'pr-11' : 'pr-4', )} {...inputProps} onKeyDown={(event) => { @@ -333,7 +333,7 @@ export function Search() { useEffect(() => { setModifierKey( - /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform) ? '⌘' : 'Ctrl ' + /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform) ? '⌘' : 'Ctrl ', ) }, []) diff --git a/components/SidebarNavigation.jsx b/components/SidebarNavigation.jsx index c8b1619..a17f681 100644 --- a/components/SidebarNavigation.jsx +++ b/components/SidebarNavigation.jsx @@ -3,34 +3,33 @@ import clsx from 'clsx' import { gql } from '@apollo/client' export const SidebarNavigationFragment = gql` -fragment SidebarNavigationFragment on RootQuery { - menuItems(first: 100 where: {location: PRIMARY}) { - nodes { - id - label - title: label - href: uri - parentId + fragment SidebarNavigationFragment on RootQuery { + menuItems(first: 100, where: { location: PRIMARY }) { + nodes { + id + label + title: label + href: uri + parentId + } } } -} ` -const isActiveSection = (section, currentNode ) => { - if ( ! currentNode ) { - return false; +const isActiveSection = (section, currentNode) => { + if (!currentNode) { + return false } - let isActive = false; + let isActive = false section.links.forEach((link) => { - if ( link.href.includes(currentNode?.uri ) ) { - isActive = true; + if (link.href.includes(currentNode?.uri)) { + isActive = true } - }); - - return isActive; + }) + return isActive } export function SidebarNavigation({ className, data, navigation }) { @@ -40,7 +39,14 @@ export function SidebarNavigation({ className, data, navigation }) { {navigation.map((section) => ( - +
{section.title}
@@ -48,21 +54,23 @@ export function SidebarNavigation({ className, data, navigation }) { role="list" className="mt-2 space-y-2 border-l-2 border-slate-100 dark:border-slate-800 lg:mt-4 lg:space-y-4 lg:border-slate-200" > - { isActiveSection(section, data?.node) ? section.links.map((link) => ( -- - {link.title} - - - )) : null } + {isActiveSection(section, data?.node) + ? section.links.map((link) => ( ++ + {link.title} + + + )) + : null} ))} diff --git a/components/SiteFooter.jsx b/components/SiteFooter.jsx index be89f10..4cb1adc 100644 --- a/components/SiteFooter.jsx +++ b/components/SiteFooter.jsx @@ -1,9 +1,15 @@ import clsx from 'clsx' export function SiteFooter({ navigation }) { - return ( - - ) -} \ No newline at end of file + // eslint-disable-next-line no-console + console.log({ navigation }) + return ( + + ) +} diff --git a/components/SiteHeader.jsx b/components/SiteHeader.jsx index 4852e8c..7bd09f9 100644 --- a/components/SiteHeader.jsx +++ b/components/SiteHeader.jsx @@ -11,49 +11,57 @@ import { GitHubIcon } from '@/components/icons/GitHubIcon' import { WordPressIcon } from '@/components/icons/WordPressIcon' export function SiteHeader({ navigation }) { - let [isScrolled, setIsScrolled] = useState(false) - - useEffect(() => { - function onScroll() { - setIsScrolled(window.scrollY > 0) - } - onScroll() - window.addEventListener('scroll', onScroll, { passive: true }) - return () => { - window.removeEventListener('scroll', onScroll) - } - }, []) - - return ( -- - ) -} \ No newline at end of file + let [isScrolled, setIsScrolled] = useState(false) + + useEffect(() => { + function onScroll() { + setIsScrolled(window.scrollY > 0) + } + onScroll() + window.addEventListener('scroll', onScroll, { passive: true }) + return () => { + window.removeEventListener('scroll', onScroll) + } + }, []) + + return ( +--- - --- - - --- --- - - - - - - + + ) +} diff --git a/components/ThemeSelector.jsx b/components/ThemeSelector.jsx index 706ba1e..516891d 100644 --- a/components/ThemeSelector.jsx +++ b/components/ThemeSelector.jsx @@ -54,8 +54,8 @@ export function ThemeSelector(props) { setSelectedTheme( themes.find( (theme) => - theme.value === document.documentElement.getAttribute('data-theme') - ) + theme.value === document.documentElement.getAttribute('data-theme'), + ), ) } }, [selectedTheme]) @@ -64,8 +64,8 @@ export function ThemeSelector(props) { let handler = () => setSelectedTheme( themes.find( - (theme) => theme.value === (window.localStorage.theme ?? 'system') - ) + (theme) => theme.value === (window.localStorage.theme ?? 'system'), + ), ) window.addEventListener('storage', handler) @@ -103,7 +103,7 @@ export function ThemeSelector(props) { 'text-slate-900 dark:text-white': active && !selected, 'text-slate-700 dark:text-slate-400': !active && !selected, 'bg-slate-100 dark:bg-slate-900/40': active, - } + }, ) } > @@ -115,7 +115,7 @@ export function ThemeSelector(props) { 'h-4 w-4', selected ? 'fill-sky-400 dark:fill-sky-400' - : 'fill-slate-400' + : 'fill-slate-400', )} />+++ + +++ + + +++ +++ + + + + + + ) } -const ListItem = React.forwardRef(({ className, title, children, ...props }, ref) => { - return ( - {navigation.map((item) => { - if (item.links.length == 0) { return ( - - )})} + ) + })}+ {item?.label} @@ -57,65 +59,71 @@ export function TopNavigation({ navigation }) {{item?.label} - { - item.links.map((sublink) => { - if (sublink.menuItemMeta?.isFeatured) { - return ( -
- -
- ) - } else { - return ( -- - {/* -*/} - - {sublink?.label} --- {sublink.menuItemMeta?.description} -
- -- {sublink.menuItemMeta?.description} - - ); - } - }) - } + {item.links.map((sublink) => { + if (sublink.menuItemMeta?.isFeatured) { + return ( +- +
+ ) + } else { + return ( ++ + {/* +*/} + + {sublink?.label} +++ {sublink.menuItemMeta?.description} +
+ ++ {sublink.menuItemMeta?.description} + + ) + } + })}- - ) -}) -ListItem.displayName = "ListItem" +const ListItem = React.forwardRef( + ({ className, title, children, ...props }, ref) => { + return ( +- - -{title}-- {children} -
- -+ + ) + }, +) +ListItem.displayName = 'ListItem' diff --git a/components/icons/GitHubIcon.jsx b/components/icons/GitHubIcon.jsx index 554bd0b..552ff58 100644 --- a/components/icons/GitHubIcon.jsx +++ b/components/icons/GitHubIcon.jsx @@ -4,4 +4,4 @@ export function GitHubIcon(props) {+ + +{title}++ {children} +
+ +) -} \ No newline at end of file +} diff --git a/components/icons/WordPressIcon.jsx b/components/icons/WordPressIcon.jsx index 53739cf..8a4f534 100644 --- a/components/icons/WordPressIcon.jsx +++ b/components/icons/WordPressIcon.jsx @@ -1,7 +1,7 @@ export function WordPressIcon(props) { return ( -