UNPKG

@stackend/api

Version:

JS bindings to api.stackend.com

99 lines 2.66 kB
import { Thunk } from '../api'; export interface Location { hash: string; host: string; hostName: string; href: string; origin: string; pathname: string; port: number; protocol: string; search: string; query: { [name: string]: string; }; } export declare enum AnchorType { BLOG = "blog", USER = "user", SITE = "site", COMMENT = "comment", TAGS = "tags", FORUM = "forum" } /** * An object representing the parsed part of an anchor link. * Used to load relevant data and for jumping to objects. */ export interface StackendAnchor { type: string; permalink: string; items?: Array<StackendAnchor>; reference?: any; userId?: number; sitePermalink?: string; pagePermalink?: string; blogKey?: string; blogEntryPermalink?: string; referenceId?: number; id?: number; tags?: string[]; forumPermalink?: string; forumThreadPermalink?: string; } /** * An implementation neutral object that keeps track of the current url and some extra stackend specific data */ export interface Request { location: Location; /** Client cookie */ cookie: string | null; /** Absolute url to the node server */ absoluteUrl: string; /** Path to the current community, if any */ communityUrl: string; /** Absolute url to the current community, if any */ absoluteCommunityUrl: string; /** The community has been determined from the domain name rather than the path */ communityFromDomain: boolean; /** Context path for the node server */ contextPath: string; /** Reference url id */ referenceUrlId: number; anchor: StackendAnchor | null; } /** * Get the request object */ export declare function getRequest(): Thunk<Request>; /** * Construct the string version of an anchor * @param anchor * @returns {string} */ export declare function formatAnchor(anchor: StackendAnchor): string; /** * Get the element id for an anchor * @param anchor * @returns {null} */ export declare function getAnchorId(anchor: StackendAnchor): string | null; /** * Parse the stackend anchor * @param anchor * @returns {StackendAnchor|null} */ export declare function parseAnchor(anchor: string | null): StackendAnchor | null; /** * Get a specific part of an anchor * @param anchor * @param type * @returns {StackendAnchor|null} */ export declare function getAnchorPart(anchor: StackendAnchor | null, type: AnchorType): StackendAnchor | null; /** * Scroll to a stackend anchor * @param anchor */ export declare function scrollToAnchor(anchor: StackendAnchor): void; //# sourceMappingURL=index.d.ts.map