remove-page-path-tail.d.ts 638 B

123456789101112131415
  1. /**
  2. * Removes the file extension for a page and the trailing `index` if it exists
  3. * making sure to not return an empty string. The page head is not touched
  4. * and returned as it is passed. Examples:
  5. * - `/foo/bar/baz/index.js` -> `/foo/bar/baz`
  6. * - `/foo/bar/baz.js` -> `/foo/bar/baz`
  7. *
  8. * @param pagePath A page to a page file (absolute or relative)
  9. * @param options.extensions Extensions allowed for the page.
  10. * @param options.keepIndex When true the trailing `index` is _not_ removed.
  11. */
  12. export declare function removePagePathTail(pagePath: string, options: {
  13. extensions: string[];
  14. keepIndex?: boolean;
  15. }): string;