Compare commits

...

11 Commits

Author SHA1 Message Date
github-actions[bot]
41c6b4d5b7 chore: update versions (#226)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-02-22 14:52:59 +01:00
Pilou
2e1c0555c7 fix: import axios in using require() to avoid XMLHttpRequest is not defined (#225)
See: https://github.com/vitejs/vite/discussions/6397
2022-02-22 14:29:34 +01:00
github-actions[bot]
764b8818dc chore: update versions (#217) 2022-02-22 09:42:20 +01:00
Pilou
03562aff43 fix: build main package in CJS instead of UMD so it works in NodeJS environments (#219)
* fix: build main package in CJS instead of UMD so it works in NodeJS environments

* chore: changeset
2022-02-22 09:36:20 +01:00
Nirmalya Ghosh
6fd14867cc fix: adds missing lang identifier for code block (#218) 2022-02-22 06:11:34 +01:00
Pilou
a8805839e9 Catchup with PRs from legacy repository (#191)
* fix: correct roles type in User. See https://github.com/nhost/hasura-auth-js/pull/15

* feat: add metadata option see https://github.com/nhost/hasura-auth-js/pull/18

* fix: correct types

fix #190

* Remove comment

* Bump Auth and hasura versions

* Create dirty-turkeys-fetch.md
2022-02-21 12:42:07 +01:00
Szilárd Dóró
9e94363724 increased clickable area of navigation links in Docs (#216) 2022-02-21 11:03:09 +01:00
Szilárd Dóró
48a9986103 docs: Improved mobile navigation (#213)
* improved Docs header appearance on desktop and mobile

* added support for dynamic menu loading for all available pages

* fixed link formatting errors in navigation
added support for auto-closing navigation when a menu is selected
fixed Newsletter responsivity

* simplified NavDataProvider
improved variable names related to the enhanced navigation
improved TypeScript definitions

* fixed ref related console error

* fixed buttons in Safari

* restructured next/link to prevent issues caused by event bubbling

* fixed an issue where mobile menu logo didn't close the menu

* made markdown links consistently root relative to fix #168
2022-02-18 08:24:47 +01:00
Szilárd Dóró
3a04d88890 Clickable sidebar section headers in Docs (#208)
* made the entire section header clickable in Docs
* fixed sidebar list item keys in Docs
2022-02-16 15:56:15 +01:00
Szilárd Dóró
b618c23a95 Improved TypeScript definitions of MDX components (#207) 2022-02-16 11:27:41 +01:00
Szilárd Dóró
0d4c88d4cd Fixed font size and font weight of list items in Docs (#206) 2022-02-16 11:25:01 +01:00
53 changed files with 894 additions and 542 deletions

View File

@@ -12,7 +12,8 @@ const pkg = require(path.join(PWD, 'package.json'))
export const lib = { export const lib = {
entry: path.resolve(PWD, 'src/index.ts'), entry: path.resolve(PWD, 'src/index.ts'),
name: pkg.name, name: pkg.name,
fileName: 'index' fileName: 'index',
formats: ['cjs', 'es']
} }
export const basePlugins = [ export const basePlugins = [
tsconfigPaths(), tsconfigPaths(),

6
docs/CHANGELOG.md Normal file
View File

@@ -0,0 +1,6 @@
# nhost-documentation
## null
### Patch Changes
- 03562af: Build in CommonJS and ESM instead of UMD and ESM as the UMD bundle generated by the default Vite lib build mode doesn't work with NodeJS

View File

@@ -2,12 +2,10 @@ import Text from '@/components/ui/Text'
import { motion } from 'framer-motion' import { motion } from 'framer-motion'
import { useRouter } from 'next/dist/client/router' import { useRouter } from 'next/dist/client/router'
import React, { useState } from 'react' import React, { useState } from 'react'
import createKebabCase from '../utils/createKebabCase' import createKebabCase from '../utils/createKebabCase'
import Permalink from './icons/Permalink' import Permalink from './icons/Permalink'
// import { ReactNode, useState } from 'react'; export interface AnchorLinkProps {
interface AnchorLinkProps {
children?: any children?: any
id?: string id?: string
size?: 'tiny' | 'small' | 'normal' | 'large' | 'big' | 'heading' size?: 'tiny' | 'small' | 'normal' | 'large' | 'big' | 'heading'
@@ -72,9 +70,8 @@ export default function AnchorLink({ children, id, size, className }: AnchorLink
href={createKebabCase( href={createKebabCase(
`#${isQuoted ? (children.props ? children.props.children : children) : children}` `#${isQuoted ? (children.props ? children.props.children : children) : children}`
)} )}
size={size ? size : 'big'}
color="greyscaleDark" color="greyscaleDark"
className="font-medium" className="font-medium break-all"
> >
{children} {children}
</Text> </Text>

View File

@@ -32,6 +32,7 @@ export function Content({ mdxSource, components, frontmatter }) {
href={getGithubLink(router.query.category, router.query.subcategory, router.query.post)} href={getGithubLink(router.query.category, router.query.subcategory, router.query.post)}
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
type={null}
> >
Edit This Page Edit This Page
<GithubIcon className="w-3.5 h-3.5 ml-1.5 text-greyscaleDark self-center" /> <GithubIcon className="w-3.5 h-3.5 ml-1.5 text-greyscaleDark self-center" />

View File

@@ -30,6 +30,7 @@ export default function Footer() {
variant="secondary" variant="secondary"
className="md:visible invisible mr-2 text-white cursor-pointer" className="md:visible invisible mr-2 text-white cursor-pointer"
href="mailto:hello@nhost.io" href="mailto:hello@nhost.io"
type={null}
> >
Contact Us Contact Us
</Button> </Button>
@@ -40,6 +41,7 @@ export default function Footer() {
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
className="cursor-pointer" className="cursor-pointer"
type={null}
> >
<span className="md:block hidden">Sign up or Log in</span> <span className="md:block hidden">Sign up or Log in</span>
<span className="md:hidden">Sign up</span> <span className="md:hidden">Sign up</span>

View File

@@ -1,26 +1,26 @@
import { MenuIcon } from '@heroicons/react/outline' import { useNavData } from '@/components/NavDataContext'
import { ArrowLeftIcon, MenuIcon } from '@heroicons/react/outline'
import clsx from 'clsx' import clsx from 'clsx'
import { useRouter } from 'next/dist/client/router' import { useRouter } from 'next/dist/client/router'
import Link from 'next/link' import Link from 'next/link'
import React, { useEffect } from 'react' import React, { MouseEvent, useEffect, useState } from 'react'
import { useState } from 'react'
import Button from '../components/ui/Button' import Button from '../components/ui/Button'
import { Nav } from './Nav'
export default function Header() { export default function Header() {
const [mobileMenu, setMobileMenu] = useState(false) const [mobileMenu, setMobileMenu] = useState(false)
const router = useRouter() const router = useRouter()
const GithubStarsCounter = () => { const GithubStarsCounter = () => {
const repoUrl = `https://api.github.com/repos/nhost/nhost` const repoUrl = `https://api.github.com/repos/nhost/nhost`
const [count, setCount] = useState(null); const [count, setCount] = useState(null)
const format = n => n > 1000 ? `${(n / 1000).toFixed(1)}k` : n; const format = (n: number) => (n > 1000 ? `${(n / 1000).toFixed(1)}k` : n)
useEffect(() => { useEffect(() => {
(async () => { ;(async () => {
const data = await fetch(repoUrl).then(res => res.json()); const data = await fetch(repoUrl).then((res) => res.json())
setCount(data.stargazers_count); setCount(data.stargazers_count)
})(); })()
}, []); }, [repoUrl])
return ( return (
<a <a
@@ -40,154 +40,234 @@ export default function Header() {
</a> </a>
) )
} }
function handleMobileMenuOpen() {
setMobileMenu(true)
}
function handleMobileMenuClose() {
setMobileMenu(false)
}
if (mobileMenu) {
return <MobileNav onClose={handleMobileMenuClose} />
}
return ( return (
<div className="bg-white md:max-w-full drop"> <header className="bg-white md:max-w-full menu-card rounded-md px-4 py-0.5 mx-2">
{mobileMenu ? ( <div className="md:max-w-header2 mx-auto font-display flex flex-row antialiased">
<MobileNav setMobileMenu={setMobileMenu} mobileMenu={mobileMenu} /> <div className="flex flex-row w-full mx-auto place-content-between py-2">
) : ( <div className="flex flex-row">
<div className="md:max-w-header2 mx-auto font-display flex flex-row antialiased px-4 "> <button
<div className="flex flex-row w-full mx-auto place-content-between py-2"> className="md:hidden w-8 h-8 flex items-center justify-center cursor-pointer text-greyscaleDark"
<div className="flex flex-row"> aria-label="Open menu"
<div className="md:hidden"> onClick={handleMobileMenuOpen}
<MenuIcon >
className="h-8 w-8 cursor-pointer text-greyscaleDark" <MenuIcon className="h-6 w-6" />
aria-hidden="true" </button>
onClick={() => setMobileMenu(!mobileMenu)}
/> <Link href="/get-started" passHref>
</div> <a className="hidden ml-3 sm:ml-0 self-center md:flex flex-row cursor-pointer">
<img src="/images/nhost-docs.svg" width={110} height={35} alt="Nhost white logo" />
<h1 className="self-center ml-6 font-medium text-greyscaleDark">DOCS</h1>
</a>
</Link>
<div className="ml-20 hidden md:flex flex-row self-center ">
<ul className="flex flex-row items-center self-center antialiased font-medium text-greyscaleGrey font-display">
<Link href="/get-started" passHref={true}>
<a
className={clsx(
'cursor-pointer text-base- self-center hover:text-greyscaleDark transition-colors duration-200 py-3',
router.query.category === 'get-started' && 'text-greyscaleDark'
)}
>
Get Started
</a>
</Link>
<Link href="/platform" passHref={true}>
<a
className={clsx(
'ml-12 cursor-pointer text-base- self-center hover:text-greyscaleDark transition-colors duration-200 py-3',
router.query.category === 'platform' && 'text-greyscaleDark'
)}
>
Platform
</a>
</Link>
<Link href="/reference" passHref={true}>
<a
className={clsx(
'ml-12 cursor-pointer text-base- self-center hover:text-greyscaleDark transition-colors duration-200 py-3',
router.query.category === 'reference' && 'text-greyscaleDark'
)}
>
Reference
</a>
</Link>
</ul>
</div>
</div>
<div className="hidden sm:flex self-center">
<GithubStarsCounter />
<Button
className="self-center"
variant="primary"
href={'https://app.nhost.io'}
Component="a"
target="_blank"
rel="noreferrer"
type={null}
>
Go to Nhost
</Button>
</div>
</div>
</div>
</header>
)
}
export type MobileNavProps = {
onClose?: VoidFunction
}
export function MobileNav({ onClose }: MobileNavProps) {
const { getConvolutedNavByCategory } = useNavData()
const router = useRouter()
const [selectedMenuSlug, setSelectedMenuSlug] = useState<string | null>(null)
const [selectedMenuName, setSelectedMenuName] = useState<string | null>(null)
function handleMenuSelect(event: MouseEvent<HTMLAnchorElement>, slug: string, name: string) {
event.preventDefault()
setSelectedMenuSlug(slug)
setSelectedMenuName(name)
}
function clearMenuSelection() {
setSelectedMenuSlug(null)
setSelectedMenuName(null)
}
return (
<div className="bg-white menu-card rounded-lg px-4 pb-6 max-w-full mx-2">
<div className="flex flex-col w-full py-3 mx-auto">
<div className="grid grid-flow-col justify-between items-center">
{!selectedMenuSlug && (
<>
<button
className="w-8 h-8 flex items-center justify-center cursor-pointer text-greyscaleDark"
aria-label="Close menu"
onClick={onClose}
>
<MenuIcon className="h-6 w-6" aria-hidden="true" />
</button>
<Link href="/get-started" passHref> <Link href="/get-started" passHref>
<a className="hidden ml-3 sm:ml-0 self-center md:flex flex-row cursor-pointer"> <a
className="ml-3 sm:ml-0 self-center flex flex-row cursor-pointer"
onClick={onClose}
>
<img <img
src="/images/nhost-docs.svg" src="/images/nhost-docs.svg"
width={110} width={110}
height={35} height={35}
alt="Nhost white logo" alt="Nhost white logo"
/> />
<h1 className="self-center ml-6 font-medium text-greyscaleDark">DOCS</h1> <h1 className="self-center ml-5 font-medium text-greyscaleDark">DOCS</h1>
</a> </a>
</Link> </Link>
</>
)}
<div className="ml-20 hidden md:flex flex-row self-center "> {selectedMenuSlug && (
<ul className="flex flex-row items-center self-center antialiased font-medium text-greyscaleGrey font-display"> <button
<Link href="/get-started" passHref={true}> className="ml-2 h-8 grid grid-flow-col gap-2 items-center justify-center cursor-pointer text-greyscaleDark"
<a aria-label="Go back to main menu"
className={clsx( onClick={clearMenuSelection}
'cursor-pointer text-base- self-center hover:text-greyscaleDark transition-colors duration-200 py-3', >
router.query.category === 'get-started' && 'text-greyscaleDark' <ArrowLeftIcon className="h-4 w-4" aria-hidden="true" />{' '}
)} <span className="font-medium text-base-">{selectedMenuName}</span>
> </button>
Get Started )}
</a>
</Link>
<Link href="/platform" passHref={true}>
<a
className={clsx(
'ml-12 cursor-pointer text-base- self-center hover:text-greyscaleDark transition-colors duration-200 py-3',
router.query.category === 'platform' && 'text-greyscaleDark'
)}
>
Platform
</a>
</Link>
<Link href="/reference" passHref={true}> {/* Placeholder for making logo appear correctly in the middle */}
<a <div className="w-8 h-8" />
className={clsx( </div>
'ml-12 cursor-pointer text-base- self-center hover:text-greyscaleDark transition-colors duration-200 py-3',
router.query.category === 'reference' && 'text-greyscaleDark' <div className="flex flex-col py-6 mt-4 border-divide border-t border-b">
)} {!selectedMenuSlug && (
> <ul className="flex flex-col font-medium text-greyscaleDark text-base- font-display space-y-4 text-left px-4">
Reference <li
</a> className={clsx(
</Link> 'cursor-pointer text-base- hover:text-greyscaleDark transition-colors duration-200 text-left ',
</ul> router.query.category === 'get-started' && 'text-greyscaleDark'
</div> )}
</div>
<div className="hidden sm:flex self-center">
<GithubStarsCounter />
<Button
className="self-center"
variant="primary"
href={'https://app.nhost.io'}
Component="a"
target="_blank"
rel="noreferrer"
> >
Go to Nhost <Link href="/get-started" passHref>
</Button> <a
</div> className="block"
</div> onClick={(event) => handleMenuSelect(event, 'get-started', 'Get Started')}
</div> >
)} Get Started
</div> </a>
) </Link>
} </li>
<li
className={clsx(
'cursor-pointer text-base- hover:text-greyscaleDark transition-colors duration-200 text-left',
router.query.category === 'platform' && 'text-greyscaleDark'
)}
>
<Link href="/platform">
<a
className="block"
onClick={(event) => handleMenuSelect(event, 'platform', 'Platform')}
>
Platform
</a>
</Link>
</li>
<li
className={clsx(
'cursor-pointer text-base- hover:text-greyscaleDark transition-colors duration-200',
router.query.category === 'reference' && 'text-greyscaleDark'
)}
>
<Link href="/reference">
<a
className="block"
onClick={(event) => handleMenuSelect(event, 'reference', 'Reference')}
>
Reference
</a>
</Link>
</li>
</ul>
)}
export function MobileNav({ setMobileMenu, mobileMenu }) { {selectedMenuSlug && (
const router = useRouter() <Nav
return ( category={selectedMenuSlug}
<div className="bg-white rounded-sm shadow-sm drop w-full "> categoryTitle={selectedMenuName}
<div className="flex flex-col w-full py-3 mx-auto "> convolutedNav={getConvolutedNavByCategory(selectedMenuSlug)}
<div className="flex flex-row"> onMenuSelected={onClose}
<div className="md:hidden">
<MenuIcon
className="h-8 w-8 cursor-pointer text-greyscaleDark"
aria-hidden="true"
onClick={() => setMobileMenu(!mobileMenu)}
/> />
</div> )}
<div className="mx-auto">
<Link href="/" passHref>
<a className="md:hidden ml-3 sm:ml-0 self-center flex flex-row cursor-pointer">
<img src="/images/nhost-docs.svg" width={110} height={35} alt="Nhost white logo" />
<h1 className="self-center ml-5 font-medium text-greyscaleDark">DOCS</h1>
</a>
</Link>
</div>
</div>
<div className="flex py-6 mt-4 border-divide border-t border-b ">
<ul className="flex flex-col font-medium text-greyscaleDark text-base- font-display space-y-4 text-left px-4 ">
<li
className={clsx(
'cursor-pointer text-base- hover:text-greyscaleDark transition-colors duration-200 text-left ',
router.query.category === 'get-started' && 'text-greyscaleDark'
)}
>
<Link href="/get-started" passHref={true}>
Get Started
</Link>
</li>
<li
className={clsx(
'cursor-pointer text-base- hover:text-greyscaleDark transition-colors duration-200 text-left',
router.query.category === 'platform' && 'text-greyscaleDark'
)}
>
<Link href="/platform" passHref={true}>
<a>Platform</a>
</Link>
</li>
<li
className={clsx(
'cursor-pointer text-base- hover:text-greyscaleDark transition-colors duration-200',
router.query.category === 'reference' && 'text-greyscaleDark'
)}
>
<Link href="/reference" passHref={true}>
<a>Reference</a>
</Link>
</li>
</ul>
</div> </div>
</div> </div>
<div className="sm:flex self-center py-2"> <div className="sm:flex self-center py-2">
<Button <Button
className="self-center" className="self-center"
variant="primary" variant="primary"
href={'https://app.nhost.io'} href="https://app.nhost.io"
Component="a" Component="a"
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
type={null}
> >
Go to Nhost Go to Nhost
</Button> </Button>

View File

@@ -10,7 +10,7 @@ import Copy from '../icons/Copy'
// @ts-ignore -> add to types // @ts-ignore -> add to types
SyntaxHighlighter.registerLanguage('js', js) SyntaxHighlighter.registerLanguage('js', js)
interface CodeEditorProps { export interface CodeEditorProps {
code: string code: string
fileName: string fileName: string
className: string className: string

View File

@@ -1,14 +1,15 @@
import AnchorLink from '@/components/AnchorLink' import AnchorLink, { AnchorLinkProps } from '@/components/AnchorLink'
import CodeComponent from '@/components/MDX/CodeComponent' import CodeComponent, { CodeEditorProps } from '@/components/MDX/CodeComponent'
import Text from '@/components/ui/Text' import Text, { TextProps } from '@/components/ui/Text'
import clsx from 'clsx'
import Image from 'next/image' import Image from 'next/image'
import Link from 'next/link' import Link from 'next/link'
import React from 'react' import React, { DetailedHTMLProps, HTMLProps, PropsWithChildren } from 'react'
import Command from '../Command' import Command from '../Command'
import Divider from '../Divider' import Divider from '../Divider'
function Note({ children }) { function Note({ children }: PropsWithChildren<unknown>) {
return ( return (
<div className="px-5 py-5 my-5 space-y-2 text-white rounded-md bg-verydark"> <div className="px-5 py-5 my-5 space-y-2 text-white rounded-md bg-verydark">
<Text className="text-white">Note</Text> <Text className="text-white">Note</Text>
@@ -17,57 +18,70 @@ function Note({ children }) {
) )
} }
function Video({ src }) { function Video({
src,
...props
}: DetailedHTMLProps<HTMLProps<HTMLSourceElement>, HTMLSourceElement>) {
return ( return (
<div className="flex justify-center my-8 mx-10"> <div className="flex justify-center my-8 mx-10">
<video width="800" controls> <video width="800" controls>
<source src={src} type="video/mp4" /> <source src={src} type="video/mp4" {...props} />
</video> </video>
</div> </div>
) )
} }
const CustomLink = (props) => { const CustomLink = ({
const href = props.href className,
const isInternalLink = href && (href.startsWith('/') || href.startsWith('#')) children,
href,
...props
}: DetailedHTMLProps<HTMLProps<HTMLAnchorElement>, HTMLAnchorElement>) => {
const isInternalLink = href && ['./', '../', '/', '#'].some((symbol) => href.startsWith(symbol))
if (isInternalLink) { if (isInternalLink) {
return ( return (
<Link href={href}> <Link href={href} passHref>
<a {...props} className="font-medium text-blue"> <a className={clsx('font-medium text-blue', className)} {...props}>
{props.children} {children}
</a> </a>
</Link> </Link>
) )
} }
return ( return (
<a target="_blank" className="font-medium text-blue" rel="noopener noreferrer" {...props} /> <a
target="_blank"
className={clsx('font-medium text-blue', className)}
rel="noopener noreferrer"
href={href}
{...props}
>
{children}
</a>
) )
} }
const components = { const components = {
img: (props) => { img: (props: DetailedHTMLProps<HTMLProps<HTMLImageElement>, HTMLImageElement>) => {
return ( return (
<> <span className="block mt-5 mx-10 ">
<span className="block mt-5 mx-10 "> <img src={props.src} alt={props.alt} className="mx-auto border mt-2" />
<img src={props.src} alt={props.alt} className="mx-auto border mt-2" /> {props.alt && (
{props.alt && ( <div className="block text-center text-secondary text-sm mb-8 pt-4">
<div className="block text-center text-secondary text-sm mb-8 pt-4"> <Text color="greyscaleDark" size="tiny">
<Text color="greyscaleDark" size="tiny"> {props.alt}
{props.alt} </Text>
</Text> </div>
</div> )}
)} </span>
</span>
</>
) )
}, },
Video, Video,
Image, Image,
Text, Text,
Note, Note,
code: (props) => { code: (props: CodeEditorProps) => {
if (props.className && props.className.includes('language')) { if (props.className && props.className.includes('language')) {
return <CodeComponent {...props} /> return <CodeComponent {...props} />
} else { } else {
@@ -76,50 +90,46 @@ const components = {
}, },
Divider, Divider,
a: CustomLink, a: CustomLink,
h1: (props) => { h1: (props: AnchorLinkProps) => {
return ( return (
<> <>
<Divider /> <Divider />
<AnchorLink {...props} size="heading" className="cursor-pointer" /> <AnchorLink {...props} className="cursor-pointer text-3xl md:text-4xl" />
</> </>
) )
}, },
h2: (props) => { h2: (props: AnchorLinkProps) => {
return ( return (
<> <div className="mt-10">
<div className="mt-10"> <AnchorLink {...props} className="cursor-pointer text-lg sm:text-xl md:text-2.5xl" />
<AnchorLink {...props} size="big" className="cursor-pointer" /> </div>
</div>
</>
) )
}, },
h3: (props) => { h3: (props: AnchorLinkProps) => {
return ( return (
<> <div className="mt-8">
<div className="mt-8"> <AnchorLink {...props} className="cursor-pointer text-lg" />
<AnchorLink {...props} size="large" className="cursor-pointer" /> </div>
</div>
</>
) )
}, },
h4: (props) => { h4: (props: AnchorLinkProps) => {
return ( return (
<> <div className="mt-4">
<div className="mt-4"> <AnchorLink {...props} className="font-bold cursor-pointer text-base-" />
<AnchorLink {...props} size="normal" className="font-bold cursor-pointer" /> </div>
</div>
</>
) )
}, },
p: (props) => ( p: (props: TextProps) => {
<Text return (
variant="body" <Text
size="small" variant="body"
color="dark" size="small"
className="my-2 antialiased leading-6" color="dark"
{...props} className="my-2 antialiased leading-6"
/> {...props}
) />
)
}
} }
export default components export default components

View File

@@ -2,104 +2,127 @@ import Text from '@/components/ui/Text'
import clsx from 'clsx' import clsx from 'clsx'
import Link from 'next/link' import Link from 'next/link'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import React from 'react' import { ParsedUrlQuery } from 'querystring'
import React, { MouseEvent } from 'react'
import { fixTitle } from '../utils/fixTitle' import { fixTitle } from '../utils/fixTitle'
import { NavItem } from './NavDataContext'
export function Nav(props) { export type NavProps = {
/**
* Class name to apply to the wrapper element.
*/
className?: string
/**
* Category slug.
*/
category: string
/**
* The category title.
*/
categoryTitle: string
/**
* Convoluted navigation.
*/
convolutedNav: NavItem[]
/**
* Function to be called when a menu item is selected.
*/
onMenuSelected?: (event?: MouseEvent<HTMLAnchorElement, MouseEvent>) => void
}
export function Nav({ className, onMenuSelected, ...props }: NavProps) {
const router = useRouter() const router = useRouter()
return ( return (
<div className="hidden lg:flex lg:min-w-nav lg:w-nav flex-col space-y-5 antialiased mt-1"> <div className={clsx('lg:min-w-nav lg:w-nav flex-col space-y-5 antialiased mt-1', className)}>
<div> <div>
<ul> <ul>
<Link href={`/${props.category}`} passHref> <li
<li className={clsx(
className={clsx( 'transition duration-300 ease-in-out rounded-md hover:text-black hover:bg-veryLightGray',
'cursor-pointer py-1 px-3 transition duration-300 ease-in-out rounded-md hover:text-black hover:bg-veryLightGray', router.query.category === props.category &&
router.query.category === props.category && !router.query.subcategory &&
!router.query.subcategory && !router.query.post &&
!router.query.post && 'bg-veryLightGray'
'bg-veryLightGray' )}
)} >
> <Link href={`/${props.category}`} passHref>
<Text <Text
variant="a" variant="a"
color="greyscaleDark" color="greyscaleDark"
size="normal" size="normal"
className={clsx( className={clsx(
'transition-colors duration-300 ease-in-out text-greyscaleDark hover:text-dark subpixel-antialiased', 'block py-1.5 px-3 transition-colors duration-300 ease-in-out text-greyscaleDark hover:text-dark subpixel-antialiased',
'font-medium' 'font-medium'
)} )}
onClick={onMenuSelected}
> >
{props.categoryTitle} {props.categoryTitle}
</Text> </Text>
</li> </Link>
</Link> </li>
</ul> </ul>
</div> </div>
{props.convolutedNav.map((elem) => { {props.convolutedNav.map((elem) => {
const parentCategory = props.category.replace(' ', '-')
return ( return (
<> <div key={elem.category}>
<div key={elem.category} className=""> <Link href={`/${parentCategory}/${elem.category}/`} passHref>
{/* <Link <Text
href={`/${props.category.replace(" ", "-")}/${elem.category}`} variant="a"
passHref color="greyscaleGrey"
> */} size="normal"
<div className="cursor-pointer"> className="block px-3 py-px font-medium capitalize"
<Link href={`/${props.category.replace(' ', '-')}/${elem.category}/`} passHref> onClick={onMenuSelected}
<Text >
variant="a" {/* Split */}
color="greyscaleGrey" {fixTitle(elem)}
size="normal" </Text>
className="font-medium capitalize px-3" </Link>
<ul className="mt-1 space-y-1 ">
{elem.posts.map((post) => {
const pathToLink =
post.fileName != 'index'
? `/${parentCategory}/${elem.category}/${post.fileName}`
: `/${parentCategory}/${elem.category}`
const shouldHighlight =
router.query.subcategory === elem.category && router.query.post === post.fileName
const shouldHighlightSubcategories =
!router.query.post &&
post.fileName === 'index' &&
elem.category === router.query.subcategory
return (
<li
className={clsx(
'transition duration-300 ease-in-out rounded-md hover:text-black hover:bg-veryLightGray',
(shouldHighlight || shouldHighlightSubcategories) && 'bg-veryLightGray'
)}
key={pathToLink}
> >
{/* Split */} <Link href={pathToLink} passHref>
{fixTitle(elem)} <Text
</Text> variant="a"
</Link> color="greyscaleDark"
</div> size="normal"
{/* </Link> */}
<ul className="space-y-1 mt-1 ">
{elem.posts.map((post) => {
const pathToLink =
post.fileName != 'index'
? `${props.pathname}/${elem.category}/${post.fileName}`
: `${props.pathname}/${elem.category}`
const shouldHiglight =
router.query.subcategory === elem.category && props.query.post === post.fileName
const shouldHighlightSubCategories =
!router.query.post &&
post.fileName === 'index' &&
elem.category === router.query.subcategory
return (
<Link href={pathToLink} passHref key={post}>
<li
className={clsx( className={clsx(
'cursor-pointer py-1 px-3 transition duration-300 ease-in-out rounded-md hover:text-black hover:bg-veryLightGray', 'py-1.5 px-3 block transition-colors duration-300 ease-in-out text-greyscaleDark hover:text-dark subpixel-antialiased block',
(shouldHiglight || shouldHighlightSubCategories) && 'bg-veryLightGray' (shouldHighlight || shouldHighlightSubcategories) && 'font-medium'
)} )}
onClick={onMenuSelected}
> >
<Text {post.title}
variant="a" </Text>
color="greyscaleDark"
size="normal"
className={clsx(
'transition-colors duration-300 ease-in-out text-greyscaleDark hover:text-dark subpixel-antialiased',
(shouldHiglight || shouldHighlightSubCategories) && 'font-medium'
)}
>
{post.title}
</Text>
</li>
</Link> </Link>
) </li>
})} )
</ul> })}
</div> </ul>
</> </div>
) )
})} })}
</div> </div>

View File

@@ -0,0 +1,85 @@
import { ParsedUrlQuery } from 'querystring'
import { createContext, PropsWithChildren, useContext } from 'react'
export type Post = {
/**
* Title of the post.
*/
title: string
/**
* File name where the post is located.
*/
fileName: string
/**
* Order of posts.
*/
order: string[]
}
export type NavItem = {
/**
* Slug of the category.
*/
category: string
/**
* List of posts in the category.
*/
posts: Post[]
}
export type NavDataContextProps = {
/**
* Category slug.
*/
category: string
/**
* The category title.
*/
categoryTitle: string
/**
* Convoluted navigation.
*/
convolutedNav: NavItem[]
/**
* Available menu items for all categories.
*/
availableCategoryMenus: {
/**
* Slug of the category.
*/
slug: string
/**
* Menu items of the category.
*/
items: NavItem[]
}[]
}
export const NavDataContext = createContext<NavDataContextProps>(null)
export function NavDataProvider({ children, ...props }: PropsWithChildren<NavDataContextProps>) {
return <NavDataContext.Provider value={props}>{children}</NavDataContext.Provider>
}
export function useNavData() {
const context = useContext(NavDataContext)
if (!context) {
throw new Error(`"useNavData" must be used within a "NavDataProvider"`)
}
/**
* Returns all of the navigation items for the specified category.
*
* @param slug Slug of the category.
* @returns All of the navigation items for the specified category.
*/
function getConvolutedNavByCategory(slug: string) {
return (
context.availableCategoryMenus.find(({ slug: category }) => category === slug)?.items ||
context.convolutedNav
)
}
return { getConvolutedNavByCategory, ...context }
}

View File

@@ -7,8 +7,11 @@ import Loading from './ui/Loading'
function NewsletterForm(props) { function NewsletterForm(props) {
return ( return (
<div className=" flex flex-row w-64 mt-5"> <div className="flex flex-row w-64 mt-5">
<form className=" flex flex-row" onSubmit={(e) => props.subscribe(e)}> <form
className="grid grid-flow-row sm:grid-flow-col gap-4"
onSubmit={(e) => props.subscribe(e)}
>
<Input <Input
color="dark" color="dark"
placeholder="Email address" placeholder="Email address"
@@ -32,7 +35,7 @@ function NewsletterError({ errorMessage, retry }) {
? errorMessage.split('.').slice(0, 2).join('.') ? errorMessage.split('.').slice(0, 2).join('.')
: errorMessage : errorMessage
return ( return (
<div className="flex flex-row mt-5"> <div className="grid grid-flow-row md:grid-flow-col gap-4 mt-5">
<p className="text-white font-normal text-sm mt-2.5">{formattedError}.</p> <p className="text-white font-normal text-sm mt-2.5">{formattedError}.</p>
<button <button
className="btn-subscribe font-display text-greyscaleDark font-medium cursor-pointer" className="btn-subscribe font-display text-greyscaleDark font-medium cursor-pointer"

View File

@@ -1,8 +1,15 @@
import cn from 'classnames' import cn from 'classnames'
import React, { CSSProperties, FunctionComponent, JSXElementConstructor } from 'react' import React, {
CSSProperties,
ForwardedRef,
forwardRef,
FunctionComponent,
JSXElementConstructor
} from 'react'
import mergeRefs from 'react-merge-refs'
import s from './Text.module.css' import s from './Text.module.css'
interface TextProps { export interface TextProps {
variant?: Variant variant?: Variant
className?: string className?: string
style?: CSSProperties style?: CSSProperties
@@ -23,20 +30,23 @@ type Size = 'tiny' | 'small' | 'normal' | 'large' | 'big' | 'heading'
type Color = 'dark' | 'grey' | 'blue' | 'greyscaleDark' | 'greyscaleGrey' | 'red' | 'white' type Color = 'dark' | 'grey' | 'blue' | 'greyscaleDark' | 'greyscaleGrey' | 'red' | 'white'
export const Text: FunctionComponent<TextProps> = ({ export const Text: FunctionComponent<TextProps> = forwardRef(function DefaultText(
style, {
className = '', style,
variant = 'body', className = '',
color, variant = 'body',
children, color,
html, children,
onClick, html,
size, onClick,
rel, size,
href, rel,
target, href,
name target,
}) => { name
},
ref: ForwardedRef<HTMLElement>
) {
const componentsMap: { const componentsMap: {
[P in Variant]: React.ComponentType<any> | string [P in Variant]: React.ComponentType<any> | string
} = { } = {
@@ -72,6 +82,7 @@ export const Text: FunctionComponent<TextProps> = ({
return ( return (
<Component <Component
ref={ref}
className={cn( className={cn(
s.root, s.root,
{ {
@@ -107,6 +118,6 @@ export const Text: FunctionComponent<TextProps> = ({
{children} {children}
</Component> </Component>
) )
} })
export default Text export default Text

View File

@@ -1 +1,2 @@
export * from './Text'
export { default } from './Text' export { default } from './Text'

View File

@@ -30,6 +30,6 @@ JavaScript and TypeScript functions run your custom code in the backend.
## Get started ## Get started
Follow our [Quick start](./get-started/quick-start) guide to build your first app. Follow our [Quick start](/get-started/quick-start) guide to build your first app.
Check out [Nhost on GitHub](https://github.com/nhost/nhost). Give us a star, and feel free to open a discussion for any feature requests as well. Check out [Nhost on GitHub](https://github.com/nhost/nhost). Give us a star, and feel free to open a discussion for any feature requests as well.

View File

@@ -78,7 +78,7 @@ await nhost.auth.signIn({
A user can be created anonymously. This is useful for offering a limited version of your application to your users without having them sign in first. A user can be created anonymously. This is useful for offering a limited version of your application to your users without having them sign in first.
An anonymous user gets a user ID with the `anonymous` role. This role can be used to [set permissions in Hasura](../database/permissions). An anonymous user gets a user ID with the `anonymous` role. This role can be used to [set permissions in Hasura](/platform/database/permissions).
### Deanonymize users ### Deanonymize users

View File

@@ -36,7 +36,7 @@ query {
## Creating users ## Creating users
Users should be created using the sign-up or sign-in flows as described under [sign-in methods](./sign-in-methods). Users should be created using the sign-up or sign-in flows as described under [sign-in methods](/platform/authentication/sign-in-methods).
**Never** create users directly via GraphQL or database. **Never** modify the `auth.users` table. **Never** modify the GraphQL root queries. **Never** create users directly via GraphQL or database. **Never** modify the `auth.users` table. **Never** modify the GraphQL root queries.

View File

@@ -6,28 +6,28 @@ This section:
### Database ### Database
- [Schema](./platform/database) - [Schema](/platform/database)
- [Permissions](./platform/database/permissions) - [Permissions](/platform/database/permissions)
- [GraphQL](./platform/database/graphql) - [GraphQL](/platform/database/graphql)
### Authentication ### Authentication
- [Authentication overview](./platform/authentication) - [Authentication overview](/platform/authentication)
- [User management](./platform/authentication/user-management) - [User management](/platform/authentication/user-management)
- [Sign-in methods](./platform/authentication/sign-in-methods) - [Sign-in methods](/platform/authentication/sign-in-methods)
- [Social login](./platform/authentication/social-login) - [Social login](/platform/authentication/social-login)
### Storage ### Storage
- [File storage](./platform/storage) - [File storage](/platform/storage)
### Serverless functions ### Serverless functions
- [Creating functions](./platform/serverless-functions) - [Creating functions](/platform/serverless-functions)
- [Event triggers](./platform/serverless-functions/event-triggers) - [Event triggers](/platform/serverless-functions/event-triggers)
### Nhost ### Nhost
- [Environment variables](./platform/nhost/environment-variables) - [Environment variables](/platform/nhost/environment-variables)
- [GitHub integration](./platform/nhost/github-integration) - [GitHub integration](/platform/nhost/github-integration)
- [Local development](./platform/nhost/local-development) - [Local development](/platform/nhost/local-development)

View File

@@ -20,7 +20,7 @@ Specifically, the following will be deployed:
## Workflow ## Workflow
Create a new Nhost app. Then use [Nhost CLI](./local-development) to initialize your Nhost app locally. Create a new Nhost app. Then use [Nhost CLI](/platform/nhost/local-development) to initialize your Nhost app locally.
The workflow is as follows: The workflow is as follows:

View File

@@ -4,6 +4,6 @@ title: 'Overview'
Documentation for other platform features: Documentation for other platform features:
- [Environment variables](./nhost/environment-variables) - [Environment variables](/platform/nhost/environment-variables)
- [GitHub integration](./nhost/github-integration) - [GitHub integration](/platform/nhost/github-integration)
- [Local development](./nhost/local-development) - [Local development](/platform/nhost/local-development)

View File

@@ -14,7 +14,7 @@ Event triggers are managed in Hasura. Go to Hasura, then select **Events** in th
![Creating event trigger in Hasura](/images/platform/hasura-create-event-trigger.png) ![Creating event trigger in Hasura](/images/platform/hasura-create-event-trigger.png)
Nhost's [environment variables](../nhost/environment-variables) can be used in event trigger headers. For example, you can attach `NHOST_WEBHOOK_SECRET` to an outgoing webhook here. Nhost's [environment variables](/platform/nhost/environment-variables) can be used in event trigger headers. For example, you can attach `NHOST_WEBHOOK_SECRET` to an outgoing webhook here.
--- ---

View File

@@ -6,17 +6,17 @@ In this section:
### Nhost SDK ### Nhost SDK
- [Overview](./reference/sdk) - [Overview](/reference/sdk)
- [GraphQL](./reference/sdk/graphql) - [GraphQL](/reference/sdk/graphql)
- [Authentication](./reference/sdk/authentication) - [Authentication](/reference/sdk/authentication)
- [Storage](./reference/sdk/storage) - [Storage](/reference/sdk/storage)
- [Functions](./reference/sdk/functions) - [Functions](/reference/sdk/functions)
### Nhost CLI ### Nhost CLI
- [CLI overview](./reference/cli) - [CLI overview](/reference/cli)
### Supporting libraries ### Supporting libraries
- [@nhost/react-auth](./reference/supporting-libraries/react-auth) - [@nhost/react-auth](/reference/supporting-libraries/react-auth)
- [@nhost/react-apollo](./reference/supporting-libraries/react-apollo) - [@nhost/react-apollo](/reference/supporting-libraries/react-apollo)

View File

@@ -5,10 +5,10 @@ subtitle: 'Nhost JavaScript SDK.'
Nhost SDK is the primary way of interacting with your Nhost app. It exposes a standard interface for each of the following services: Nhost SDK is the primary way of interacting with your Nhost app. It exposes a standard interface for each of the following services:
- [GraphQL](./sdk/graphql) - [GraphQL](/reference/sdk/graphql)
- [Authentication](./sdk/authentication) - [Authentication](/reference/sdk/authentication)
- [Storage](./sdk/storage) - [Storage](/reference/sdk/storage)
- [Functions](./sdk/functions) - [Functions](/reference/sdk/functions)
## Installation ## Installation

View File

@@ -6,5 +6,5 @@ We offer libraries and plugins for specific frameworks to make integration with
Currently, the following supporting libraries are available: Currently, the following supporting libraries are available:
- [@nhost/react-apollo](./supporting-libraries/react-apollo) - [@nhost/react-apollo](/reference/supporting-libraries/react-apollo)
- [@nhost/react-auth](./supporting-libraries/react-auth) - [@nhost/react-auth](/reference/supporting-libraries/react-auth)

View File

@@ -10,7 +10,7 @@ title: '@nhost/react-auth'
Install `@nhost/react-auth` and its dependencies: Install `@nhost/react-auth` and its dependencies:
``` ```sh
npm install @nhost/nhost-js @nhost/react-auth npm install @nhost/nhost-js @nhost/react-auth
``` ```

View File

@@ -42,5 +42,6 @@
"tailwindcss": "^2.2.19", "tailwindcss": "^2.2.19",
"typescript": "^4.5.2" "typescript": "^4.5.2"
}, },
"prettier": "../prettier.config.js" "prettier": "../prettier.config.js",
"version": null
} }

View File

@@ -4,50 +4,68 @@ import Footer from '@/components/Footer'
import Header from '@/components/Header' import Header from '@/components/Header'
import components from '@/components/MDX/components' import components from '@/components/MDX/components'
import { Nav } from '@/components/Nav' import { Nav } from '@/components/Nav'
import { NavDataProvider } from '@/components/NavDataContext'
import { createConvolutedNav } from '@/lib/post' import { createConvolutedNav } from '@/lib/post'
import { capitalize } from '@/utils/capitalize' import { capitalize } from '@/utils/capitalize'
import fs from 'fs' import fs from 'fs'
import matter from 'gray-matter' import matter from 'gray-matter'
import { serialize } from 'next-mdx-remote/serialize' import { serialize } from 'next-mdx-remote/serialize'
import Head from 'next/head' import Head from 'next/head'
import { useRouter } from 'next/router'
import { join } from 'path' import { join } from 'path'
import React from 'react' import React from 'react'
import { Main } from '../components/Main' import { Main } from '../components/Main'
export default function Home({ category, frontmatter, mdxSource, convolutedNav, categoryTitle }) { export default function Home({
const router = useRouter() category,
const pathname = `/${router.query.category}` frontmatter,
mdxSource,
convolutedNav,
availableCategoryMenus,
categoryTitle
}) {
return ( return (
<div className="bg-white"> <NavDataProvider
<Head> category={category}
<title> categoryTitle={categoryTitle}
{frontmatter.title} {capitalize(category)} | Nhost Documentation convolutedNav={convolutedNav}
</title> availableCategoryMenus={availableCategoryMenus}
</Head> >
<Header /> <div className="bg-white pt-2">
<Container> <Head>
<Nav <title>
categoryTitle={categoryTitle} {frontmatter.title} - {capitalize(category)} | Nhost Documentation
convolutedNav={convolutedNav} </title>
category={category} </Head>
query={router.query} <Header />
pathname={pathname} <Container>
/> <Nav
<Main> className="hidden lg:flex"
<Content mdxSource={mdxSource} components={components} frontmatter={frontmatter} /> categoryTitle={categoryTitle}
</Main> convolutedNav={convolutedNav}
</Container> category={category}
<Footer /> />
</div>
<Main>
<Content mdxSource={mdxSource} components={components} frontmatter={frontmatter} />
</Main>
</Container>
<Footer />
</div>
</NavDataProvider>
) )
} }
export async function getStaticProps({ params }) { export async function getStaticProps({ params }) {
const postsDirectory = join(process.cwd(), 'content', 'docs') const postsDirectory = join(process.cwd(), 'content', 'docs')
const convolutedNav = createConvolutedNav(params.category) const availableCategories = fs.readdirSync(postsDirectory)
const availableCategoryMenus = availableCategories.map((category) => ({
slug: category,
items: createConvolutedNav(category)
}))
const convolutedNav =
availableCategoryMenus.find(({ slug }) => slug === params.category).items ||
createConvolutedNav(params.category)
const categoryTitle = matter( const categoryTitle = matter(
fs.readFileSync(join(postsDirectory, `${params.category}/index.mdx`), 'utf8') fs.readFileSync(join(postsDirectory, `${params.category}/index.mdx`), 'utf8')
@@ -64,7 +82,8 @@ export async function getStaticProps({ params }) {
category: params.category, category: params.category,
frontmatter: { ...data }, frontmatter: { ...data },
mdxSource, mdxSource,
convolutedNav: convolutedNav availableCategoryMenus,
convolutedNav
} }
} }
} }
@@ -84,6 +103,7 @@ export async function getStaticPaths(props) {
paths: paths.map((category) => { paths: paths.map((category) => {
return { return {
params: { params: {
availableCategories: paths,
category category
} }
} }

View File

@@ -4,16 +4,15 @@ import Footer from '@/components/Footer'
import Header from '@/components/Header' import Header from '@/components/Header'
import components from '@/components/MDX/components' import components from '@/components/MDX/components'
import { Nav } from '@/components/Nav' import { Nav } from '@/components/Nav'
import { NavDataProvider } from '@/components/NavDataContext'
import { createConvolutedNav, getAllPosts } from '@/lib/post' import { createConvolutedNav, getAllPosts } from '@/lib/post'
import { capitalize } from '@/utils/capitalize' import { capitalize } from '@/utils/capitalize'
import fs from 'fs' import fs from 'fs'
import matter from 'gray-matter' import matter from 'gray-matter'
import { serialize } from 'next-mdx-remote/serialize' import { serialize } from 'next-mdx-remote/serialize'
import Head from 'next/head' import Head from 'next/head'
import { useRouter } from 'next/router'
import { join } from 'path' import { join } from 'path'
import React from 'react' import React from 'react'
import { Main } from '../../components/Main' import { Main } from '../../components/Main'
import { SubNavigation } from '../../components/SubNavigation' import { SubNavigation } from '../../components/SubNavigation'
import { TopNavigation } from '../../components/TopNavigation' import { TopNavigation } from '../../components/TopNavigation'
@@ -25,47 +24,60 @@ export default function Post({
mdxSource, mdxSource,
convolutedNav, convolutedNav,
post, post,
categoryTitle categoryTitle,
availableCategoryMenus
}) { }) {
const router = useRouter()
const pathname = `/${router.query.category}`
return ( return (
<div className="bg-white"> <NavDataProvider
<Head> category={category}
<title> categoryTitle={categoryTitle}
{frontmatter.title} {capitalize(category)} | Nhost Documentation convolutedNav={convolutedNav}
</title> availableCategoryMenus={availableCategoryMenus}
</Head> >
<Header /> <div className="bg-white pt-2">
<Container> <Head>
<Nav <title>
convolutedNav={convolutedNav} {frontmatter.title} - {capitalize(category)} | Nhost Documentation
category={category} </title>
categoryTitle={categoryTitle} </Head>
query={router.query} <Header />
pathname={pathname} <Container>
/> <Nav
className="hidden lg:flex"
<Main>
<TopNavigation category={category} subcategory={subcategory} />
<Content mdxSource={mdxSource} components={components} frontmatter={frontmatter} />
<SubNavigation
convolutedNav={convolutedNav} convolutedNav={convolutedNav}
category={category} category={category}
post={post} categoryTitle={categoryTitle}
subcategory={subcategory}
/> />
</Main>
</Container> <Main>
<Footer /> <TopNavigation category={category} subcategory={subcategory} />
</div>
<Content mdxSource={mdxSource} components={components} frontmatter={frontmatter} />
<SubNavigation
convolutedNav={convolutedNav}
category={category}
post={post}
subcategory={subcategory}
/>
</Main>
</Container>
<Footer />
</div>
</NavDataProvider>
) )
} }
export async function getStaticProps({ params }) { export async function getStaticProps({ params }) {
const postsDirectory = join(process.cwd(), 'content', 'docs') const postsDirectory = join(process.cwd(), 'content', 'docs')
const convolutedNav = createConvolutedNav(params.category) const availableCategories = fs.readdirSync(postsDirectory)
const availableCategoryMenus = availableCategories.map((category) => ({
slug: category,
items: createConvolutedNav(category)
}))
const convolutedNav =
availableCategoryMenus.find(({ slug }) => slug === params.category).items ||
createConvolutedNav(params.category)
const fullPath = join(postsDirectory, `${params.category}/${params.subcategory}/index.mdx`) const fullPath = join(postsDirectory, `${params.category}/${params.subcategory}/index.mdx`)
const categoryTitle = matter( const categoryTitle = matter(
@@ -83,7 +95,8 @@ export async function getStaticProps({ params }) {
subcategory: params.subcategory, subcategory: params.subcategory,
frontmatter: { ...data }, frontmatter: { ...data },
mdxSource, mdxSource,
convolutedNav: convolutedNav availableCategoryMenus,
convolutedNav
} }
} }
} }

View File

@@ -4,20 +4,17 @@ import Footer from '@/components/Footer'
import Header from '@/components/Header' import Header from '@/components/Header'
import components from '@/components/MDX/components' import components from '@/components/MDX/components'
import { Nav } from '@/components/Nav' import { Nav } from '@/components/Nav'
import { NavDataProvider } from '@/components/NavDataContext'
import { SubNavigation } from '@/components/SubNavigation' import { SubNavigation } from '@/components/SubNavigation'
import { TopNavigation } from '@/components/TopNavigation' import { TopNavigation } from '@/components/TopNavigation'
import { createConvolutedNav, getAllPosts, getHeadingsByPost, removeIndexFile } from '@/lib/post' import { createConvolutedNav, getAllPosts, removeIndexFile } from '@/lib/post'
import { capitalize } from '@/utils/capitalize' import { capitalize } from '@/utils/capitalize'
import fs from 'fs' import fs from 'fs'
import matter from 'gray-matter' import matter from 'gray-matter'
import { serialize } from 'next-mdx-remote/serialize' import { serialize } from 'next-mdx-remote/serialize'
import { useRouter } from 'next/dist/client/router'
import Head from 'next/head' import Head from 'next/head'
import { join } from 'path' import { join } from 'path'
import React from 'react' import React from 'react'
// import { PostMetadata } from "../../../components/PostMetadata";
// import { HeadingsNavigation } from "../../../components/HeadingsNavigation";
import { Main } from '../../../components/Main' import { Main } from '../../../components/Main'
export default function Post({ export default function Post({
@@ -25,61 +22,64 @@ export default function Post({
subcategory, subcategory,
frontmatter, frontmatter,
mdxSource, mdxSource,
nav,
convolutedNav, convolutedNav,
availableCategoryMenus,
post, post,
headings,
categoryTitle categoryTitle
}) { }) {
const router = useRouter()
const pathname = `/${router.query.category}`
return ( return (
<div className="bg-white"> <NavDataProvider
<Head> category={category}
<title> categoryTitle={categoryTitle}
{frontmatter.title} {capitalize(subcategory)} - {capitalize(category)} | Nhost convolutedNav={convolutedNav}
Documentation availableCategoryMenus={availableCategoryMenus}
</title> >
</Head> <div className="bg-white pt-2">
<Header /> <Head>
<Container> <title>
<Nav {frontmatter.title} - {capitalize(subcategory)} - {capitalize(category)} | Nhost
convolutedNav={convolutedNav} Documentation
category={category} </title>
categoryTitle={categoryTitle} </Head>
nav={nav} <Header />
query={router.query} <Container>
pathname={pathname} <Nav
headings={headings} className="hidden lg:flex"
/>
<Main>
<TopNavigation category={category} subcategory={subcategory} />
<Content mdxSource={mdxSource} components={components} frontmatter={frontmatter} />
<SubNavigation
convolutedNav={convolutedNav} convolutedNav={convolutedNav}
category={category} category={category}
post={post} categoryTitle={categoryTitle}
subcategory={subcategory}
/> />
{/* <PostMetadata
category={category} <Main>
subcategory={subcategory} <TopNavigation category={category} subcategory={subcategory} />
frontmatter={frontmatter}
post={post} <Content mdxSource={mdxSource} components={components} frontmatter={frontmatter} />
/> */}
</Main> <SubNavigation
{/* <HeadingsNavigation headings={headings} /> */} convolutedNav={convolutedNav}
</Container> category={category}
<Footer /> post={post}
</div> subcategory={subcategory}
/>
</Main>
</Container>
<Footer />
</div>
</NavDataProvider>
) )
} }
export async function getStaticProps({ params }) { export async function getStaticProps({ params }) {
const postsDirectory = join(process.cwd(), 'content', 'docs') const postsDirectory = join(process.cwd(), 'content', 'docs')
const convolutedNav = createConvolutedNav(params.category) const availableCategories = fs.readdirSync(postsDirectory)
const availableCategoryMenus = availableCategories.map((category) => ({
slug: category,
items: createConvolutedNav(category)
}))
const convolutedNav =
availableCategoryMenus.find(({ slug }) => slug === params.category).items ||
createConvolutedNav(params.category)
const categoryTitle = matter( const categoryTitle = matter(
fs.readFileSync(join(postsDirectory, `${params.category}/index.mdx`), 'utf8') fs.readFileSync(join(postsDirectory, `${params.category}/index.mdx`), 'utf8')
@@ -91,7 +91,6 @@ export async function getStaticProps({ params }) {
) )
const fileContents = fs.readFileSync(fullPath, 'utf8') const fileContents = fs.readFileSync(fullPath, 'utf8')
const { data, content } = matter(fileContents) const { data, content } = matter(fileContents)
const headings = getHeadingsByPost(content)
const mdxSource = await serialize(content) const mdxSource = await serialize(content)
return { return {
@@ -102,8 +101,8 @@ export async function getStaticProps({ params }) {
post: params.post, post: params.post,
frontmatter: { ...data }, frontmatter: { ...data },
mdxSource, mdxSource,
headings: headings, availableCategoryMenus,
convolutedNav: convolutedNav convolutedNav
} }
} }
} }

View File

@@ -1,21 +1,24 @@
import Footer from '@/components/Footer' import Footer from '@/components/Footer'
import Header from '@/components/Header' import Header from '@/components/Header'
import { NavDataProvider } from '@/components/NavDataContext'
import Text from '@/components/ui/Text' import Text from '@/components/ui/Text'
import Head from 'next/head' import Head from 'next/head'
export default function Home() { export default function Home() {
return ( return (
<div className="bg-fafafa"> <NavDataProvider category="" categoryTitle="" convolutedNav={[]} availableCategoryMenus={[]}>
<Head> <div className="bg-fafafa pt-2">
<title>Nhost Documentation</title> <Head>
</Head> <title>Nhost Documentation</title>
<Header /> </Head>
<div className="flex flex-row max-w-5xl pb-20 mx-auto space-x-20 mt-36 bg-fafafa"> <Header />
<div className="h-screen"> <div className="flex flex-row max-w-5xl pb-20 mx-auto space-x-20 mt-36 bg-fafafa">
<Text>Welcome to Nhost</Text> <div className="h-screen">
<Text>Welcome to Nhost</Text>
</div>
</div> </div>
<Footer />
</div> </div>
<Footer /> </NavDataProvider>
</div>
) )
} }

View File

@@ -1,36 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url><loc>https://docs.nhost.io</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.955Z</lastmod></url> <url><loc>https://docs.nhost.io</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/cli-workflow/install-cli</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/cli-workflow/local-changes</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/cli-workflow/metadata-and-serverless-functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start/javascript-client</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/cli-workflow/workflow-setup</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start/permissions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/quick-start/javascript-client</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start/schema</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/quick-start/permissions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/sign-in-methods</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/quick-start/schema</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/social-login</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/authentication/sign-in-methods</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/user-management</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/authentication/social-login</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/database/graphql</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/authentication/user-management</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/database/permissions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/database/graphql</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost/environment-variables</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/database/permissions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost/github-integration</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/nhost/environment-variables</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost/local-development</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/nhost/github-integration</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/serverless-functions/event-triggers</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/nhost/local-development</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/serverless-functions/event-triggers</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/reference/sdk/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/graphql</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/reference/sdk/functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/storage</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/reference/sdk/graphql</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/supporting-libraries/react-apollo</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/reference/sdk/storage</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/supporting-libraries/react-auth</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/reference/supporting-libraries/react-apollo</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/reference/supporting-libraries/react-auth</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/upgrade</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/cli-workflow</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/quick-start</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/database</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/get-started/upgrade</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/serverless-functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/database</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/storage</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/nhost</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/cli</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/serverless-functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/platform/storage</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/supporting-libraries</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-08T09:55:24.956Z</lastmod></url> <url><loc>https://docs.nhost.io/reference/cli</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/supporting-libraries</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-22T08:04:43.021Z</lastmod></url>
</urlset> </urlset>

View File

@@ -69,7 +69,6 @@ body {
flex: none; flex: none;
order: 1; order: 1;
flex-grow: 0; flex-grow: 0;
margin: 0px 16px;
} }
@responsive { @responsive {
@@ -93,6 +92,10 @@ body {
border-radius: 4px; border-radius: 4px;
} }
.menu-card {
box-shadow: 0px 1px 4px rgba(14, 24, 39, 0.1), 0px 8px 24px rgba(14, 24, 39, 0.1);
}
.divider { .divider {
height: 1px; height: 1px;
left: 0px; left: 0px;

View File

@@ -11,7 +11,7 @@
} }
.markdown li { .markdown li {
@apply text-sm font-display text-greyscaleDark font-medium leading-7; @apply text-base- font-display text-greyscaleDark font-normal leading-7;
list-style: disc; list-style: disc;
list-style-type: disc; list-style-type: disc;
list-style-position: inside; list-style-position: inside;

View File

@@ -0,0 +1,7 @@
# @nhost-examples/testing-project
## 1.0.1
### Patch Changes
- a880583: - Improve typings (close [this PR](https://github.com/nhost/hasura-auth-js/pull/15))
- Add the metadata field introduced in [hasura-auth 0.2.0](https://github.com/nhost/hasura-auth/releases/tag/v0.2.0) (close [this PR](https://github.com/nhost/hasura-auth-js/pull/18))

View File

@@ -3,11 +3,11 @@ services:
mailhog: mailhog:
port: 8025 port: 8025
hasura: hasura:
version: v2.1.0 version: v2.2.0
environment: environment:
hasura_graphql_enable_remote_schema_permissions: false hasura_graphql_enable_remote_schema_permissions: false
auth: auth:
version: sha-c328aa7 version: 0.2.1
auth: auth:
access_control: access_control:
email: email:

View File

@@ -1,7 +1,7 @@
{ {
"name": "@nhost-examples/testing-project", "name": "@nhost-examples/testing-project",
"private": true, "private": true,
"version": "1.0.0", "version": "1.0.1",
"description": "Wrapper to run the Nhost CLI for development and testing", "description": "Wrapper to run the Nhost CLI for development and testing",
"scripts": { "scripts": {
"start": "nhost -d" "start": "nhost -d"

View File

@@ -1,6 +1,21 @@
# @nhost/hasura-auth-js # @nhost/hasura-auth-js
## 0.1.13
### Patch Changes
- 2e1c055: Axios causes some trouble when used NodeJS / CommonJS. Any code importing `axios` now does so in using the `require()` syntax
## 0.1.12
### Patch Changes
- a880583: - Improve typings (close [this PR](https://github.com/nhost/hasura-auth-js/pull/15))
- Add the metadata field introduced in [hasura-auth 0.2.0](https://github.com/nhost/hasura-auth/releases/tag/v0.2.0) (close [this PR](https://github.com/nhost/hasura-auth-js/pull/18))
- 03562af: Build in CommonJS and ESM instead of UMD and ESM as the UMD bundle generated by the default Vite lib build mode doesn't work with NodeJS
## 0.1.11 ## 0.1.11
### Patch Changes ### Patch Changes
- 7c3a7be: Remove http timeout options (fix[#157](https://github.com/nhost/nhost/issues/157)) - 7c3a7be: Remove http timeout options (fix[#157](https://github.com/nhost/nhost/issues/157))

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/hasura-auth-js", "name": "@nhost/hasura-auth-js",
"version": "0.1.11", "version": "0.1.13",
"description": "Hasura-auth client", "description": "Hasura-auth client",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@@ -29,16 +29,10 @@
"verify": "run-p prettier lint", "verify": "run-p prettier lint",
"verify:fix": "run-p prettier:fix lint:fix" "verify:fix": "run-p prettier:fix lint:fix"
}, },
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js"
}
},
"main": "src/index.ts", "main": "src/index.ts",
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
"main": "dist/index.umd.js", "main": "dist/index.cjs.js",
"module": "dist/index.es.js", "module": "dist/index.es.js",
"typings": "./dist/index.d.ts" "typings": "./dist/index.d.ts"
}, },

View File

@@ -1,4 +1,4 @@
import axios, { AxiosError, AxiosInstance } from 'axios' import type { AxiosError, AxiosInstance } from 'axios'
import { import {
ApiChangeEmailResponse, ApiChangeEmailResponse,
@@ -24,6 +24,8 @@ import {
SignUpEmailPasswordParams SignUpEmailPasswordParams
} from './utils/types' } from './utils/types'
const axios = require('axios')
const SERVER_ERROR_CODE = 500 const SERVER_ERROR_CODE = 500
export class HasuraAuthApi { export class HasuraAuthApi {
private url: string private url: string

View File

@@ -26,6 +26,8 @@ import {
ApiError, ApiError,
ApiResetPasswordResponse, ApiResetPasswordResponse,
ApiSendVerificationEmailResponse, ApiSendVerificationEmailResponse,
ApiSignInResponse,
ApiSignOutResponse,
AuthChangedFunction, AuthChangedFunction,
AuthChangeEvent, AuthChangeEvent,
ChangeEmailParams, ChangeEmailParams,
@@ -105,7 +107,6 @@ export class HasuraAuthClient {
this.initAuthLoading = true this.initAuthLoading = true
this.session = null this.session = null
// this.user = null;
this.api = new HasuraAuthApi({ url: this.url }) this.api = new HasuraAuthApi({ url: this.url })
@@ -313,7 +314,7 @@ export class HasuraAuthClient {
* *
* @docs https://docs.nhost.io/TODO * @docs https://docs.nhost.io/TODO
*/ */
async signOut(params?: { all?: boolean }): Promise<unknown> { async signOut(params?: { all?: boolean }): Promise<ApiSignOutResponse> {
const refreshToken = await this._getItem(NHOST_REFRESH_TOKEN) const refreshToken = await this._getItem(NHOST_REFRESH_TOKEN)
this._clearSession() this._clearSession()
@@ -333,10 +334,8 @@ export class HasuraAuthClient {
* *
* @docs https://docs.nhost.io/TODO * @docs https://docs.nhost.io/TODO
*/ */
async verifyEmail(params: { email: string; ticket: string }): Promise<unknown> { async verifyEmail(params: { email: string; ticket: string }): Promise<ApiSignInResponse> {
const { data, error } = await this.api.verifyEmail(params) return await this.api.verifyEmail(params)
return { data, error }
} }
/** /**

View File

@@ -7,7 +7,7 @@ export interface User {
email?: string email?: string
isAnonymous: boolean isAnonymous: boolean
defaultRole: string defaultRole: string
roles: Record<string, string> roles: string[]
} }
export interface Session { export interface Session {
@@ -32,6 +32,7 @@ export interface SignUpEmailPasswordParams {
defaultRole?: string defaultRole?: string
displayName?: string displayName?: string
redirectTo?: string redirectTo?: string
metadata?: Record<string, unknown>
} }
} }
@@ -55,6 +56,7 @@ export interface SignInPasswordlessEmailParams {
defaultRole?: string defaultRole?: string
displayName?: string displayName?: string
redirectTo?: string redirectTo?: string
metadata?: Record<string, unknown>
} }
} }
@@ -66,6 +68,7 @@ export interface SignInPasswordlessSmsParams {
defaultRole?: string defaultRole?: string
displayName?: string displayName?: string
redirectTo?: string redirectTo?: string
metadata?: Record<string, unknown>
} }
} }
@@ -92,6 +95,7 @@ export interface SignInWithProviderOptions {
defaultRole?: string defaultRole?: string
displayName?: string displayName?: string
redirectTo?: string redirectTo?: string
metadata?: Record<string, unknown>
} }
} }

View File

@@ -20,6 +20,24 @@ describe('sign-up', () => {
expect(session).toBeNull() expect(session).toBeNull()
}) })
test('sign up with metadata', async () => {
const email = faker.internet.email().toLocaleLowerCase()
const password = faker.internet.password(8)
const { session, error } = await auth.signUp({
email,
password,
options: {
metadata: {
birthDate: '1990-01-01'
}
}
})
expect(error).toBeNull()
expect(session).toBeNull()
})
it('sign up with options', async () => { it('sign up with options', async () => {
const email = faker.internet.email().toLocaleLowerCase() const email = faker.internet.email().toLocaleLowerCase()
const password = faker.internet.password(8) const password = faker.internet.password(8)

View File

@@ -1,6 +1,19 @@
# @nhost/hasura-storage-js # @nhost/hasura-storage-js
## 0.0.9
### Patch Changes
- 2e1c055: Axios causes some trouble when used NodeJS / CommonJS. Any code importing `axios` now does so in using the `require()` syntax
## 0.0.8
### Patch Changes
- 03562af: Build in CommonJS and ESM instead of UMD and ESM as the UMD bundle generated by the default Vite lib build mode doesn't work with NodeJS
## 0.0.7 ## 0.0.7
### Patch Changes ### Patch Changes
- 7c3a7be: Remove http timeout options (fix[#157](https://github.com/nhost/nhost/issues/157)) - 7c3a7be: Remove http timeout options (fix[#157](https://github.com/nhost/nhost/issues/157))

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/hasura-storage-js", "name": "@nhost/hasura-storage-js",
"version": "0.0.7", "version": "0.0.9",
"description": "Hasura-storage client", "description": "Hasura-storage client",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@@ -27,16 +27,10 @@
"verify": "run-p prettier lint", "verify": "run-p prettier lint",
"verify:fix": "run-p prettier:fix lint:fix" "verify:fix": "run-p prettier:fix lint:fix"
}, },
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js"
}
},
"main": "src/index.ts", "main": "src/index.ts",
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
"main": "dist/index.umd.js", "main": "dist/index.cjs.js",
"module": "dist/index.es.js", "module": "dist/index.es.js",
"typings": "./dist/index.d.ts" "typings": "./dist/index.d.ts"
}, },

View File

@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
import axios, { AxiosInstance } from 'axios' import type { AxiosInstance } from 'axios'
import { import {
ApiDeleteParams, ApiDeleteParams,
@@ -11,6 +11,7 @@ import {
UploadHeaders UploadHeaders
} from './utils/types' } from './utils/types'
const axios = require('axios')
export class HasuraStorageApi { export class HasuraStorageApi {
private url: string private url: string
private httpClient: AxiosInstance private httpClient: AxiosInstance

View File

@@ -1,6 +1,26 @@
# @nhost/nhost-js # @nhost/nhost-js
## 0.3.9
### Patch Changes
- 2e1c055: Axios causes some trouble when used NodeJS / CommonJS. Any code importing `axios` now does so in using the `require()` syntax
- Updated dependencies [2e1c055]
- @nhost/hasura-auth-js@0.1.13
- @nhost/hasura-storage-js@0.0.9
## 0.3.8
### Patch Changes
- 03562af: Build in CommonJS and ESM instead of UMD and ESM as the UMD bundle generated by the default Vite lib build mode doesn't work with NodeJS
- Updated dependencies [a880583]
- Updated dependencies [03562af]
- @nhost/hasura-auth-js@0.1.12
- @nhost/hasura-storage-js@0.0.8
## 0.3.7 ## 0.3.7
### Patch Changes ### Patch Changes
- Updated dependencies [7c3a7be] - Updated dependencies [7c3a7be]

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/nhost-js", "name": "@nhost/nhost-js",
"version": "0.3.7", "version": "0.3.9",
"description": "Nhost JavaScript SDK", "description": "Nhost JavaScript SDK",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@@ -20,16 +20,10 @@
"type": "git", "type": "git",
"url": "git+https://github.com/nhost/nhost.git" "url": "git+https://github.com/nhost/nhost.git"
}, },
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js"
}
},
"main": "src/index.ts", "main": "src/index.ts",
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
"main": "dist/index.umd.js", "main": "dist/index.cjs.js",
"module": "dist/index.es.js", "module": "dist/index.es.js",
"typings": "./dist/index.d.ts" "typings": "./dist/index.d.ts"
}, },

View File

@@ -1,7 +1,8 @@
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios' import type { AxiosInstance, AxiosRequestConfig } from 'axios'
import { FunctionCallResponse } from '../types' import { FunctionCallResponse } from '../types'
const axios = require('axios')
export interface NhostFunctionsConstructorParams { export interface NhostFunctionsConstructorParams {
url: string url: string
} }

View File

@@ -1,7 +1,9 @@
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios' import type { AxiosInstance, AxiosRequestConfig } from 'axios'
import { GraphqlRequestResponse, GraphqlResponse } from '../types' import { GraphqlRequestResponse, GraphqlResponse } from '../types'
const axios = require('axios')
export interface NhostGraphqlConstructorParams { export interface NhostGraphqlConstructorParams {
url: string url: string
} }

View File

@@ -1,4 +1,4 @@
import { AxiosResponse } from 'axios' import type { AxiosResponse } from 'axios'
export type GraphqlRequestResponse = export type GraphqlRequestResponse =
| { | {

View File

@@ -1,6 +1,22 @@
# @nhost/react-apollo # @nhost/react-apollo
## 2.1.1 ## 2.1.3
### Patch Changes ### Patch Changes
- @nhost/nhost-js@0.3.7 - Updated dependencies [2e1c055]
- @nhost/nhost-js@0.3.9
## 2.1.2
### Patch Changes
- 03562af: Build in CommonJS and ESM instead of UMD and ESM as the UMD bundle generated by the default Vite lib build mode doesn't work with NodeJS
- Updated dependencies [03562af]
- @nhost/nhost-js@0.3.8
## 2.1.1
### Patch Changes
- @nhost/nhost-js@0.3.7

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/react-apollo", "name": "@nhost/react-apollo",
"version": "2.1.1", "version": "2.1.3",
"description": "Nhost React Apollo client", "description": "Nhost React Apollo client",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@@ -35,14 +35,10 @@
"main": "src/index.tsx", "main": "src/index.tsx",
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
"main": "dist/index.umd.js", "main": "dist/index.cjs.js",
"module": "dist/index.es.js", "module": "dist/index.es.js",
"typings": "dist/index.d.ts" "typings": "dist/index.d.ts"
}, },
"exports": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js"
},
"dependencies": { "dependencies": {
"@nhost/nhost-js": "workspace:*", "@nhost/nhost-js": "workspace:*",
"subscriptions-transport-ws": "^0.11.0" "subscriptions-transport-ws": "^0.11.0"

View File

@@ -1,6 +1,22 @@
# @nhost/react-auth # @nhost/react-auth
## 2.0.4 ## 2.0.6
### Patch Changes ### Patch Changes
- @nhost/nhost-js@0.3.7 - Updated dependencies [2e1c055]
- @nhost/nhost-js@0.3.9
## 2.0.5
### Patch Changes
- 03562af: Build in CommonJS and ESM instead of UMD and ESM as the UMD bundle generated by the default Vite lib build mode doesn't work with NodeJS
- Updated dependencies [03562af]
- @nhost/nhost-js@0.3.8
## 2.0.4
### Patch Changes
- @nhost/nhost-js@0.3.7

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/react-auth", "name": "@nhost/react-auth",
"version": "2.0.4", "version": "2.0.6",
"description": "Nhost React client", "description": "Nhost React client",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@@ -34,14 +34,10 @@
"main": "src/index.tsx", "main": "src/index.tsx",
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
"main": "dist/index.umd.js", "main": "dist/index.cjs.js",
"module": "dist/index.es.js", "module": "dist/index.es.js",
"typings": "dist/index.d.ts" "typings": "dist/index.d.ts"
}, },
"exports": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js"
},
"dependencies": { "dependencies": {
"@nhost/nhost-js": "workspace:*" "@nhost/nhost-js": "workspace:*"
}, },