From acc4d9ae4e693f5a16e67120c590d51397a2efed Mon Sep 17 00:00:00 2001 From: Muhammad Saim Date: Tue, 29 Apr 2025 11:31:31 +0500 Subject: [PATCH 1/2] docs: update API documentation to include Postman collection link and usage --- src/components/Guides.jsx | 98 +++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 46 deletions(-) diff --git a/src/components/Guides.jsx b/src/components/Guides.jsx index 8b6e3fb..2a502a6 100644 --- a/src/components/Guides.jsx +++ b/src/components/Guides.jsx @@ -2,53 +2,59 @@ import { Button } from '@/components/Button' import { Heading } from '@/components/Heading' const guides = [ - { - href: '/authentication', - name: 'Authentication', - description: 'Learn how to authenticate your API requests.', - }, - { - href: '/pagination', - name: 'Pagination', - description: 'Understand how to work with paginated responses.', - }, - { - href: '/errors', - name: 'Errors', - description: - 'Read about the different types of errors returned by the API.', - }, - { - href: '/rate-limits', - name: 'Rate Limits', - description: - 'Understand the rate limits that apply to your API requests.', - }, + { + href: '/authentication', + name: 'Authentication', + description: 'Learn how to authenticate your API requests.', + }, + { + href: '/pagination', + name: 'Pagination', + description: 'Understand how to work with paginated responses.', + }, + { + href: '/errors', + name: 'Errors', + description: + 'Read about the different types of errors returned by the API.', + }, + { + href: '/rate-limits', + name: 'Rate Limits', + description: + 'Understand the rate limits that apply to your API requests.', + }, + { + href: 'https://github.com/luadotsh/lua', + name: 'Postman Collection', + description: + 'Access and test all API endpoints easily using the provided Postman collection.', + }, ] export function Guides() { - return ( -
- - Guides - -
- {guides.map((guide) => ( -
-

- {guide.name} -

-

- {guide.description} -

-

- -

-
- ))} -
-
- ) + return ( +
+ + Guides + +
+ {guides.map((guide) => ( +
+

+ {guide.name} +

+

+ {guide.description} +

+

+ +

+
+ ))} +
+
+ ) } From b7f1c69e59bebb31a867f88b9cb7190e9adc5634 Mon Sep 17 00:00:00 2001 From: Muhammad Saim Date: Wed, 30 Apr 2025 08:17:49 +0500 Subject: [PATCH 2/2] docs: document Postman collection usage and variable configuration - Added instructions for importing lua.sh.postman_collection.json from repo root - Described required collection variables: BASE_URL and API_TOKEN - Updated meta description for better clarity - remove section from the home page --- src/app/postman/page.mdx | 27 +++ src/components/Guides.jsx | 8 +- src/components/Navigation.jsx | 409 +++++++++++++++++----------------- 3 files changed, 233 insertions(+), 211 deletions(-) create mode 100644 src/app/postman/page.mdx diff --git a/src/app/postman/page.mdx b/src/app/postman/page.mdx new file mode 100644 index 0000000..080b162 --- /dev/null +++ b/src/app/postman/page.mdx @@ -0,0 +1,27 @@ +export const metadata = { + title: 'Postman', + description: + 'Postman collection (lua.sh.postman_collection.json) is available in the root of this repository. Import it into Postman and set the BASE_URL and API_TOKEN variables to begin testing the API.', +} + +## Postman Collection + +A Postman collection is included in the root of this repository: +**`lua.sh.postman_collection.json`** + +### Importing the Collection + +1. Open Postman. +2. Click **"Import"** and choose the **"File"** tab. +3. Select the file `lua.sh.postman_collection.json` from the repository root. + +### Environment Setup + +After import, configure the following collection variables: + +- `BASE_URL`: The base endpoint of the API (e.g., `https://api.example.com`) +- `API_TOKEN`: Authorization token for accessing protected endpoints + +These variables are required to authenticate and interact with the API successfully. + +Once configured, the collection is ready for use. diff --git a/src/components/Guides.jsx b/src/components/Guides.jsx index 2a502a6..11758b4 100644 --- a/src/components/Guides.jsx +++ b/src/components/Guides.jsx @@ -24,12 +24,6 @@ const guides = [ description: 'Understand the rate limits that apply to your API requests.', }, - { - href: 'https://github.com/luadotsh/lua', - name: 'Postman Collection', - description: - 'Access and test all API endpoints easily using the provided Postman collection.', - }, ] export function Guides() { @@ -38,7 +32,7 @@ export function Guides() { Guides -
+
{guides.map((guide) => (

diff --git a/src/components/Navigation.jsx b/src/components/Navigation.jsx index 60dfb70..13a4ca1 100644 --- a/src/components/Navigation.jsx +++ b/src/components/Navigation.jsx @@ -1,10 +1,10 @@ 'use client' -import { useRef } from 'react' -import Link from 'next/link' -import { usePathname } from 'next/navigation' import clsx from 'clsx' import { AnimatePresence, motion, useIsPresent } from 'framer-motion' +import Link from 'next/link' +import { usePathname } from 'next/navigation' +import { useRef } from 'react' import { Button } from '@/components/Button' import { useIsInsideMobileNavigation } from '@/components/MobileNavigation' @@ -13,233 +13,234 @@ import { Tag } from '@/components/Tag' import { remToPx } from '@/lib/remToPx' function useInitialValue(value, condition = true) { - let initialValue = useRef(value).current - return condition ? initialValue : value + let initialValue = useRef(value).current + return condition ? initialValue : value } function TopLevelNavItem({ href, children }) { - return ( -
  • - - {children} - -
  • - ) + return ( +
  • + + {children} + +
  • + ) } function NavLink({ - href, - children, - tag, - active = false, - isAnchorLink = false, + href, + children, + tag, + active = false, + isAnchorLink = false, }) { - return ( - - {children} - {tag && ( - - {tag} - - )} - - ) + return ( + + {children} + {tag && ( + + {tag} + + )} + + ) } function VisibleSectionHighlight({ group, pathname }) { - let [sections, visibleSections] = useInitialValue( - [ - useSectionStore((s) => s.sections), - useSectionStore((s) => s.visibleSections), - ], - useIsInsideMobileNavigation(), - ) + let [sections, visibleSections] = useInitialValue( + [ + useSectionStore((s) => s.sections), + useSectionStore((s) => s.visibleSections), + ], + useIsInsideMobileNavigation(), + ) - let isPresent = useIsPresent() - let firstVisibleSectionIndex = Math.max( - 0, - [{ id: '_top' }, ...sections].findIndex( - (section) => section.id === visibleSections[0], - ), - ) - let itemHeight = remToPx(2) - let height = isPresent - ? Math.max(1, visibleSections.length) * itemHeight - : itemHeight - let top = - group.links.findIndex((link) => link.href === pathname) * itemHeight + - firstVisibleSectionIndex * itemHeight + let isPresent = useIsPresent() + let firstVisibleSectionIndex = Math.max( + 0, + [{ id: '_top' }, ...sections].findIndex( + (section) => section.id === visibleSections[0], + ), + ) + let itemHeight = remToPx(2) + let height = isPresent + ? Math.max(1, visibleSections.length) * itemHeight + : itemHeight + let top = + group.links.findIndex((link) => link.href === pathname) * itemHeight + + firstVisibleSectionIndex * itemHeight - return ( - - ) + return ( + + ) } function ActivePageMarker({ group, pathname }) { - let itemHeight = remToPx(2) - let offset = remToPx(0.25) - let activePageIndex = group.links.findIndex((link) => link.href === pathname) - let top = offset + activePageIndex * itemHeight + let itemHeight = remToPx(2) + let offset = remToPx(0.25) + let activePageIndex = group.links.findIndex((link) => link.href === pathname) + let top = offset + activePageIndex * itemHeight - return ( - - ) + return ( + + ) } function NavigationGroup({ group, className }) { - // If this is the mobile navigation then we always render the initial - // state, so that the state does not change during the close animation. - // The state will still update when we re-open (re-render) the navigation. - let isInsideMobileNavigation = useIsInsideMobileNavigation() - let [pathname, sections] = useInitialValue( - [usePathname(), useSectionStore((s) => s.sections)], - isInsideMobileNavigation, - ) + // If this is the mobile navigation then we always render the initial + // state, so that the state does not change during the close animation. + // The state will still update when we re-open (re-render) the navigation. + let isInsideMobileNavigation = useIsInsideMobileNavigation() + let [pathname, sections] = useInitialValue( + [usePathname(), useSectionStore((s) => s.sections)], + isInsideMobileNavigation, + ) - let isActiveGroup = - group.links.findIndex((link) => link.href === pathname) !== -1 + let isActiveGroup = + group.links.findIndex((link) => link.href === pathname) !== -1 - return ( -
  • - - {group.title} - -
    - - {isActiveGroup && ( - - )} - - - - {isActiveGroup && ( - - )} - -
      - {group.links.map((link) => ( - - - {link.title} - - - {link.href === pathname && sections.length > 0 && ( - - {sections.map((section) => ( -
    • - - {section.title} - -
    • + return ( +
    • + + {group.title} + +
      + + {isActiveGroup && ( + + )} + + + + {isActiveGroup && ( + + )} + +
        + {group.links.map((link) => ( + + + {link.title} + + + {link.href === pathname && sections.length > 0 && ( + + {sections.map((section) => ( +
      • + + {section.title} + +
      • + ))} +
        + )} +
        +
        ))} - - )} - - - ))} -
      -
      -
    • - ) +
    +
    +
  • + ) } export const navigation = [ - { - title: 'Guides', - links: [ - { title: 'Introduction', href: '/' }, - { title: 'Authentication', href: '/authentication' }, - { title: 'Making Requests', href: '/requests' }, - { title: 'Rate Limits', href: '/rate-limits' }, - { title: 'Pagination', href: '/pagination' }, - { title: 'Errors', href: '/errors' }, - // { title: 'Webhooks', href: '/webhooks' }, - { title: 'API Changelog', href: '/changelog' } - ], - }, - { - title: 'Endpoints', - links: [ - { title: 'Links', href: '/links' }, - { title: 'Domains', href: '/domains' }, - { title: 'Tags', href: '/tags' }, - ], - }, - { - title: 'Hosting', - links: [ - { title: 'Self-Hosting', href: '/self-hosting' }, - { title: 'Local Development', href: '/local-development' }, - ], - }, + { + title: 'Guides', + links: [ + { title: 'Introduction', href: '/' }, + { title: 'Authentication', href: '/authentication' }, + { title: 'Making Requests', href: '/requests' }, + { title: 'Rate Limits', href: '/rate-limits' }, + { title: 'Pagination', href: '/pagination' }, + { title: 'Errors', href: '/errors' }, + // { title: 'Webhooks', href: '/webhooks' }, + { title: 'API Changelog', href: '/changelog' }, + { title: 'Postman', href: '/postman' }, + ], + }, + { + title: 'Endpoints', + links: [ + { title: 'Links', href: '/links' }, + { title: 'Domains', href: '/domains' }, + { title: 'Tags', href: '/tags' }, + ], + }, + { + title: 'Hosting', + links: [ + { title: 'Self-Hosting', href: '/self-hosting' }, + { title: 'Local Development', href: '/local-development' }, + ], + }, ] export function Navigation(props) { - return ( - - ) + return ( + + ) }