diff --git a/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts b/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts index e5eb11d9466..eb214e4963b 100644 --- a/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts +++ b/apps/docs/components/CustomHTMLElements/CustomHTMLElements.utils.ts @@ -82,8 +82,8 @@ export const highlightSelectedNavItem = (id: string) => { const navMenuItems = document.querySelectorAll('.function-link-item a') // find any currently active items and remove them - const currentActiveItem = document.querySelector('.function-link-list .text-brand-900') - currentActiveItem?.classList.remove('text-brand-900') + const currentActiveItems = document.querySelectorAll('.function-link-list .text-brand-900') + currentActiveItems.forEach((item) => item.classList.remove('text-brand-900')) // Add active class to the current item navMenuItems.forEach((item) => { diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx index bce96f36823..d84449ca809 100644 --- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx +++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx @@ -276,9 +276,24 @@ const SideNav = () => { {/* reference level */} - - - + + + ) } diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx index d8d94cf338d..059b9e2f047 100644 --- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx +++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx @@ -12,9 +12,8 @@ import Image from 'next/image' const allFunctions = Object.values(clientLibsCommonSections.sections.functions) -const introItems = Object.values(clientLibsCommonSections.sections.intro.js.items) - -const NavigationMenuRefList = ({ currentLevel, setLevel, id }) => { +const NavigationMenuRefList = ({ currentLevel, setLevel, id, lib }) => { + const introItems = Object.values(clientLibsCommonSections.sections.intro[lib].items) const router = useRouter() const menu = NavItems[id] diff --git a/apps/docs/docs/ref/dart/release-notes.mdx b/apps/docs/docs/ref/dart/release-notes.mdx new file mode 100644 index 00000000000..b5e0e218918 --- /dev/null +++ b/apps/docs/docs/ref/dart/release-notes.mdx @@ -0,0 +1,6 @@ +--- +id: release-notes +title: Release Notes +--- + +## dart this is the release notes file. diff --git a/apps/docs/pages/reference/dart/[...slug].tsx b/apps/docs/pages/reference/dart/[...slug].tsx index 80649329578..ec3d7a62720 100644 --- a/apps/docs/pages/reference/dart/[...slug].tsx +++ b/apps/docs/pages/reference/dart/[...slug].tsx @@ -21,7 +21,7 @@ import dartSpec from '~/../../spec/supabase_dart_v1_temp_new_shape.yml' assert { // @ts-expect-error import commonLibSpec from '~/../../spec/common-client-libs.yml' assert { type: 'yml' } - +import commonLibJson from '~/../../spec/common-client-libs-sections.json' import { IconDatabase, Tabs } from 'ui' import CodeBlock from '~/components/CodeBlock/CodeBlock' @@ -33,7 +33,14 @@ import RefSubLayout from '~/layouts/ref/RefSubLayout' import OldLayout from '~/layouts/Default' +import clientLibsCommonSections from '~/../../spec/common-client-libs-sections.json' + +const allFunctions = Object.values(clientLibsCommonSections.sections.functions) + .map((fn: any) => fn.items) + .flat(2) + export default function DartReference(props) { + console.log('docs', props.docs) const router = useRouter() const slug = router.query.slug[0] @@ -59,169 +66,241 @@ export default function DartReference(props) { } return ( - - {dartSpec.functions.map((item, itemIndex) => { - const hasTsRef = item['$ref'] || null - const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, jsTypeSpec) - const parameters = hasTsRef ? generateParameters(tsDefinition) : '' + <> + +
~~~Preamble pages~~~
+ {props.docs + .filter((doc) => doc.introPage) + .map((item) => ( + + + + + + ))} +
+
+ + {/* jsSpec.functions.map((item, itemIndex) => { */} + {props.docs + .filter((doc) => !doc.introPage) + .map((doc, itemIndex) => { + const item = dartSpec.functions.find((x) => x.id === doc.id) + const hasTsRef = item['$ref'] || null + const tsDefinition = hasTsRef && extractTsDocNode(hasTsRef, jsTypeSpec) + const parameters = hasTsRef ? generateParameters(tsDefinition) : '' + // const functionMarkdownContent = props?.docs[itemIndex]?.content + // ? props?.docs[itemIndex]?.content + // : null + const shortText = hasTsRef ? tsDefinition.signatures[0].comment.shortText : '' - const functionMarkdownContent = props?.docs[itemIndex]?.content - const shortText = hasTsRef ? tsDefinition.signatures[0].comment.shortText : '' + // const introFileMarkdownContent = + //console.log('props.docs', props.docs) + // if (item.id !== 'db-modifiers-select') return <> - return ( - commonItem.id === item.id).slug} - scrollSpyHeader={true} - > - + return ( <> -
- {shortText && {shortText}} -
+ commonItem.id === item.id).slug} + scrollSpyHeader={true} + > + + <> +
+ {shortText && ( + {shortText} + )} +
- {item.description && ( -
- {item.description} -
- )} - {functionMarkdownContent && ( -
- -
- )} - {item.notes && ( -
- {item.notes} -
- )} - {/* // parameters */} - {parameters && ( -
-
Parameters
-
    - {parameters.map((param) => { - // grab override params from yaml file - const overrideParams = item.overrideParams + {item.description && ( +
    + {item.description} +
    + )} + {/* {functionMarkdownContent && ( +
    + +
    + )} */} + {item.notes && ( +
    + {item.notes} +
    + )} + {/* // parameters */} + {parameters && ( +
    +
    Parameters
    +
      + {parameters.map((param) => { + // grab override params from yaml file + const overrideParams = item.overrideParams - // params from the yaml file can override the params from parameters if it matches the name - const overide = overrideParams?.filter((x) => { - return param.name === x.name - }) + // params from the yaml file can override the params from parameters if it matches the name + const overide = overrideParams?.filter((x) => { + return param.name === x.name + }) - const paramItem = overide?.length > 0 ? overide[0] : param + const paramItem = overide?.length > 0 ? overide[0] : param - return ( - - {paramItem.subContent && ( -
      - - {param.subContent.map((param) => { - return - })} - -
      - )} - - ) - })} -
    -
    - )} - - - - {item.examples && ( - <> - - {item.examples && - item.examples.map((example, exampleIndex) => { - const exampleString = ` - import { createClient } from '@supabase/supabase-js' - - // Create a single supabase client for interacting with your database - const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key') - ` - const currentExampleId = example.id - const staticExample = item.examples[exampleIndex] - - const response = staticExample.response - const sql = staticExample?.data?.sql - const tables = staticExample?.data?.tables - - return ( - - {tables && - tables.length > 0 && - tables.map((table) => { - return ( -
    -
    -
    -
    - -
    -
    {table.name}
    -
    + return ( + + {paramItem.subContent && ( +
    + + {param.subContent.map((param) => { + return + })} +
    -
    - ) - })} - {sql && ( - - {sql} - - )} - - {exampleString + - (example.code && - example.code - .replace('```', '') - .replace('js', '') - .replace('```', ''))} - - {response && ( - <> - + ) + })} +
+
+ )} + +
+ + {item.examples && ( + <> + + {item.examples && + item.examples.map((example, exampleIndex) => { + const exampleString = ` +import { createClient } from '@supabase/supabase-js' + +// Create a single supabase client for interacting with your database +const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key') +` + const currentExampleId = example.id + const staticExample = item.examples[exampleIndex] + + const response = staticExample.response + const sql = staticExample?.data?.sql + const tables = staticExample?.data?.tables + + return ( + - {response} - - - )} - - ) - })} - - - )} - -
- ) - })} -
+ {((tables && tables.length > 0) || sql) && ( + + <> + {tables && + tables.length > 0 && + tables.map((table) => { + return ( +
+
+
+
+ +
+
+ {table.name} +
+
+
+
+ ) + })} + {sql && ( + + {sql} + + )} + +
+ )} + + + {exampleString + + (example.code && + example.code + .replace('```', '') + .replace('js', '') + .replace('```', ''))} + + {response && ( + + + {response + .replace('```', '') + .replace('json', '') + .replace('```', '')} + + + )} + + ) + })} + + + )} + + + + ) + })} +
+ ) } export async function getStaticProps({ params }: { params: { slug: string[] } }) { - const pages = dartSpec.functions.map((x) => x.id) + // an array of ids of the intro sections for this library + const introPages = commonLibJson.sections.intro.dart.items.map((item) => item.id) + + const specPpages = allFunctions.filter((fn) => fn.libs.includes('dart')).map((x) => x.id) + + const pages = [...introPages, ...specPpages] /** * Read all the markdown files that might have @@ -231,7 +310,7 @@ export async function getStaticProps({ params }: { params: { slug: string[] } }) */ const allMarkdownDocs = await Promise.all( pages.map(async (x, i) => { - const pathName = `docs/ref/js/${x}.mdx` + const pathName = `docs/ref/dart/${x}.mdx` function checkFileExists(x) { // console.log('checking this ', x) @@ -254,6 +333,7 @@ export async function getStaticProps({ params }: { params: { slug: string[] } }) title: x, // ...content, meta: data, + introPage: introPages.includes(x), content: content ? await serialize(content || '') : null, } }) diff --git a/apps/docs/pages/reference/javascript/[...slug].tsx b/apps/docs/pages/reference/javascript/[...slug].tsx index d022ed4701c..457fe308325 100644 --- a/apps/docs/pages/reference/javascript/[...slug].tsx +++ b/apps/docs/pages/reference/javascript/[...slug].tsx @@ -42,6 +42,7 @@ const allFunctions = Object.values(clientLibsCommonSections.sections.functions) .flat(2) export default function JSReference(props) { + console.log('docs', props.docs) const router = useRouter() const slug = router.query.slug[0] @@ -127,9 +128,7 @@ export default function JSReference(props) { // item.id // } id={item.id} - slug={ - commonLibSpec.functions.find((commonItem) => commonItem.id === item.id).slug - } + slug={allFunctions.find((commonItem) => commonItem.id === item.id).slug} scrollSpyHeader={true} > @@ -214,8 +213,6 @@ const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key const sql = staticExample?.data?.sql const tables = staticExample?.data?.tables - const [dataOpen, setDataOpen] = useState(false) - return (