UNPKG

@aedart/vuepress-utils

Version:

A few utilities for Vuepress.

349 lines (344 loc) 8.32 kB
/** * @aedart/vuepress-utils * * BSD-3-Clause, Copyright (c) 2023-present Alin Eugen Deac <aedart@gmail.com>. */ import { Archive as Archive$1, PagesCollection as PagesCollection$1 } from '@aedart/vuepress-utils/contracts'; import { NavbarGroupOptions, NavbarLinkOptions, SidebarOptions, NavGroup, SidebarArrayOptions, SidebarObjectOptions, SidebarItemOptions } from '@vuepress/theme-default'; /** * Archive * * @typedef {import('@vuepress/theme-default').NavbarGroupOptions} NavbarGroupOptions * @typedef {import('@vuepress/theme-default').NavbarLinkOptions} NavbarLinkOptions * @typedef {import('@vuepress/theme-default').NavGroup} NavGroup * @typedef {import('@vuepress/theme-default').SidebarOptions} SidebarOptions */ declare class Archive implements Archive$1 { /** * Name of this archive * * @type {string} * @private */ private _name; /** * Archive's path * * @type {string} * @private */ private _path; /** * Collection to be marked as "current" * * @type {PagesCollection} * @private */ private _current; /** * Collection to be marked as "next" * * @type {PagesCollection} * @private */ private _next; /** * Collections in this archive * * @type {PagesCollection[]} * @private */ private _collections; /** * Navigation label for the "current" collection * * @type {string} * @private */ private _currentLabel; /** * Navigation label for the "next" collection * * @type {string} * @private */ private _nextLabel; /** * Relative path for the "current" collection, in archive * * @type {string} * @private */ private _currentPath; /** * Relative path for the "next" collection, in archive * * @type {string} * @private */ private _nextPath; /** * Creates a new Archive instance * * @param {PagesCollection} current * @param {PagesCollection} next * @param {PagesCollection[]} [collections=[]] */ constructor(current: PagesCollection$1, next: PagesCollection$1, collections?: PagesCollection$1[]); /** * Creates a new Archive instance * * @param {PagesCollection} current * @param {PagesCollection} next * @param {PagesCollection[]} [collections=[]] * * @returns {Archive} */ static make(current: PagesCollection$1, next: PagesCollection$1, collections?: PagesCollection$1[]): Archive; /** * @inheritdoc */ set name(name: string); /** * @inheritdoc */ get name(): string; /** * @inheritdoc */ set path(path: string); /** * @inheritdoc */ get path(): string; /** * @inheritdoc */ set current(collection: PagesCollection$1); /** * @inheritdoc */ get current(): PagesCollection$1; /** * @inheritdoc */ set next(collection: PagesCollection$1); /** * @inheritdoc */ get next(): PagesCollection$1; /** * @inheritdoc */ set collections(pageCollections: PagesCollection$1[]); /** * @inheritdoc */ get collections(): PagesCollection$1[]; /** * @inheritdoc */ set currentLabel(name: string); /** * @inheritdoc */ get currentLabel(): string; /** * @inheritdoc */ set nextLabel(name: string); /** * @inheritdoc */ get nextLabel(): string; /** * @inheritdoc */ set currentPath(path: string); /** * @inheritdoc */ get currentPath(): string; /** * @inheritdoc */ get currentFullPath(): string; /** * @inheritdoc */ set nextPath(path: string); /** * @inheritdoc */ get nextPath(): string; /** * @inheritdoc */ get nextFullPath(): string; /** * @inheritdoc */ asNavigationItem(): NavbarGroupOptions | NavbarLinkOptions; /** * @inheritdoc */ sidebarConfiguration(): SidebarOptions; /***************************************************************** * Internals ****************************************************************/ /** * Returns collections as list of navbar item * * @returns {(NavbarLinkOptions | NavGroup<NavbarLinkOptions>)[]} * @protected */ protected makeNavbarItemChildren(): (NavbarLinkOptions | NavGroup<NavbarLinkOptions>)[]; /** * "Mark" the current and next collections * * @param {PagesCollection[]} collections * * @returns {PagesCollection[]} * @protected */ protected markCurrentAndNextCollections(collections: PagesCollection$1[]): PagesCollection$1[]; } /** * Pages Collection * * @typedef {import('@vuepress/theme-default').NavGroup} NavGroup * @typedef {import('@vuepress/theme-default').NavbarLinkOptions} NavbarLinkOptions * @typedef {import('@vuepress/theme-default').SidebarObjectOptions} SidebarObjectOptions * @typedef {import('@vuepress/theme-default').SidebarArrayOptions} SidebarArrayOptions * @typedef {import('@vuepress/theme-default').SidebarItemOptions} SidebarItemOptions * @typedef {import('@vuepress/theme-default').SidebarGroupOptions} SidebarGroupOptions */ declare class PagesCollection implements PagesCollection$1 { /** * Name of this collection * * @type {string} * * @private */ private _name; /** * Relative path of this collection inside an archive * * @type {string} * @private */ private _path; /** * Archive that this collection belongs to * * @type {Archive | null} * @private */ private _archive; /** * The pages in this collection * * @type {SidebarArrayOptions} */ pages: SidebarArrayOptions; /** * Creates a new pages collection instance * * @param {string} name * @param {string} path * @param {SidebarArrayOptions} [pages=[]] */ constructor(name: string, path: string, pages?: SidebarArrayOptions); /** * Creates a new pages collection instance * * @param {string} name * @param {string} path * @param {SidebarArrayOptions} [pages=[]] * * @returns {PagesCollection} */ static make(name: string, path: string, pages?: SidebarArrayOptions): PagesCollection; /** * @inheritdoc */ set name(name: string); /** * @inheritdoc */ get name(): string; /** * @inheritdoc */ set path(path: string); /** * @inheritdoc */ get path(): string; /** * @inheritdoc */ get fullPath(): string; /** * @inheritdoc */ set archive(archive: Archive$1 | null); /** * @inheritdoc */ get archive(): Archive$1 | null; /** * @inheritdoc */ asNavigationItem(): NavbarLinkOptions | NavGroup<NavbarLinkOptions>; /** * @inheritdoc */ asSidebarObject(): SidebarObjectOptions; /** * @inheritdoc */ sidebar(): SidebarArrayOptions; /***************************************************************** * Internals ****************************************************************/ /** * Resolves pages' path * * @param {SidebarArrayOptions} pages * * @returns {SidebarArrayOptions} * @protected */ protected resolvePages(pages: SidebarArrayOptions): SidebarArrayOptions; /** * Resolves given page's path * * @param {SidebarItemOptions} page * * @returns {SidebarItemOptions} * * @protected */ protected resolvePage(page: SidebarItemOptions): SidebarItemOptions; /** * Prefix given path with {@link fullPath} * * @param {string} path * * @returns {string} * @protected */ protected prefixWillFullPath(path: string): string; /** * Prefix given path with {@link Archive.path} * * @param {string} path * @returns {string} * * @protected */ protected prefixWithArchivePath(path: string): string; } export { Archive, PagesCollection };