UNPKG

@scalar/api-reference

Version:

Generate beautiful API references from OpenAPI documents

54 lines 2.42 kB
import type { ApiReferenceConfiguration } from '@scalar/types/api-reference'; import type { Heading } from '@scalar/types/legacy'; import { type InjectionKey, type MaybeRefOrGetter, type Ref } from 'vue'; export type NavState = { /** The URL hash without the #, also the "hash" pulled from pathRouting */ hash: Ref<string>; /** The prefix for the hash, used in ORG */ hashPrefix: Ref<string>; /** Whether the intersection observer is enabled and updating the hash as we scroll */ isIntersectionEnabled: Ref<boolean>; basePath: MaybeRefOrGetter<string | undefined>; generateHeadingSlug: MaybeRefOrGetter<ApiReferenceConfiguration['generateHeadingSlug']>; }; export declare const NAV_STATE_SYMBOL: InjectionKey<NavState>; /** * Hook which provides reactive hash state from the URL * Also hash is only readable by the client so keep that in mind for SSR * * isIntersectionEnabled is a hack to prevent intersection observer from triggering * when clicking on sidebar links or going backwards * * @param _config this is used to pass in the config if we have not provided it yet to the useConfig hook such as in ApiReferenceLayout */ export declare const useNavState: () => { hash: Ref<string, string>; /** Sets the prefix for the hash */ setHashPrefix: (prefix: string) => void; /** * Gets the full hash with the prefix * @param hashTarget The hash to target with the return * @returns The full hash */ getFullHash: (hashTarget?: string) => string; /** * Gets the hashed url with the prefix * @param replacementHash The hash to replace the current hash with * @param url The url to get the hashed url from * @returns The hashed url */ getHashedUrl: (replacementHash: string, url?: string, search?: string) => string; /** * Replaces the URL state with the new url and hash * Replacement is used so that hash changes don't trigger the url hash watcher and cause a scroll */ replaceUrlState: (replacementHash: string, url?: string) => void; getReferenceId: () => string; getHeadingId: (heading: Heading) => string; getPathRoutingId: (pathName: string) => string; isIntersectionEnabled: Ref<boolean, boolean>; updateHash: () => string; }; /** Whats returned from the hook */ export type UseNavState = ReturnType<typeof useNavState>; //# sourceMappingURL=useNavState.d.ts.map