diff --git a/app/routes/authenticated.tsx b/app/routes/authenticated.tsx
index 75a645caab..d3132ecc1c 100644
--- a/app/routes/authenticated.tsx
+++ b/app/routes/authenticated.tsx
@@ -15,10 +15,10 @@ import useQueryNotices from "~/hooks/useQueryNotices";
import {
homePath,
settingsPath,
- matchDocumentSlug as documentSlug,
- matchCollectionSlug as collectionSlug,
+ matchCollectionNew,
matchDocumentEdit,
matchDocumentHistory,
+ matchDocumentShortlink,
} from "~/utils/routeHelpers";
import env from "~/env";
import { routeMap } from "./map";
@@ -86,11 +86,7 @@ function AuthenticatedRoutes() {
-
+
-
-
-
+
+
+
) : (
@@ -47,19 +48,15 @@ export default function Routes() {
-
-
+
+
-
+
diff --git a/app/routes/map.ts b/app/routes/map.ts
index af5f963dc6..83c506a8a4 100644
--- a/app/routes/map.ts
+++ b/app/routes/map.ts
@@ -2,16 +2,18 @@
import type * as React from "react";
import { createLazyComponent } from "~/components/LazyLoad";
import {
- archivePath,
- debugPath,
- draftsPath,
- homePath,
+ matchArchive,
+ matchChangesets,
+ matchCollection,
matchCollectionEdit,
- matchCollectionSlug,
- matchDocumentSlug,
- searchPath,
- settingsPath,
- trashPath,
+ matchDebug,
+ matchDocument,
+ matchDrafts,
+ matchHome,
+ matchSearch,
+ matchSettings,
+ matchShare,
+ matchTrash,
} from "~/utils/routeHelpers";
/**
@@ -39,29 +41,23 @@ export interface RouteMapEntry {
* prefix with.
*/
export const routeMap = {
- drafts: defineRoute(draftsPath(), () => import("~/scenes/Drafts")),
- archive: defineRoute(archivePath(), () => import("~/scenes/Archive")),
- trash: defineRoute(trashPath(), () => import("~/scenes/Trash")),
- home: defineRoute(`${homePath()}/:tab?`, () => import("~/scenes/Home")),
- search: defineRoute(
- `${searchPath()}/:query?`,
- () => import("~/scenes/Search")
- ),
+ drafts: defineRoute(matchDrafts, () => import("~/scenes/Drafts")),
+ archive: defineRoute(matchArchive, () => import("~/scenes/Archive")),
+ trash: defineRoute(matchTrash, () => import("~/scenes/Trash")),
+ home: defineRoute(matchHome, () => import("~/scenes/Home")),
+ search: defineRoute(matchSearch, () => import("~/scenes/Search")),
collection: defineRoute(
- [matchCollectionEdit, `/collection/${matchCollectionSlug}/:tab?`],
+ [matchCollectionEdit, matchCollection],
() => import("~/scenes/Collection")
),
- document: defineRoute(
- `/doc/${matchDocumentSlug}`,
- () => import("~/scenes/Document")
- ),
- settings: defineRoute(settingsPath(), () => import("./settings")),
- shared: defineRoute("/s/:shareId", () => import("~/scenes/Shared")),
+ document: defineRoute(matchDocument, () => import("~/scenes/Document")),
+ settings: defineRoute(matchSettings, () => import("./settings")),
+ shared: defineRoute(matchShare, () => import("~/scenes/Shared")),
changesets: defineRoute(
- `${debugPath()}/changesets`,
+ matchChangesets,
() => import("~/scenes/Developer/Changesets")
),
- debug: defineRoute(debugPath(), () => import("~/scenes/Developer/Debug")),
+ debug: defineRoute(matchDebug, () => import("~/scenes/Developer/Debug")),
};
function defineRoute(
diff --git a/app/scenes/Document/hooks/useDocumentSidebar.tsx b/app/scenes/Document/hooks/useDocumentSidebar.tsx
index d48f9a1ce3..785d13e706 100644
--- a/app/scenes/Document/hooks/useDocumentSidebar.tsx
+++ b/app/scenes/Document/hooks/useDocumentSidebar.tsx
@@ -14,7 +14,7 @@ import history from "~/utils/history";
import {
documentPath,
matchDocumentHistory,
- matchDocumentSlug,
+ matchDocument,
} from "~/utils/routeHelpers";
import SidebarLayout from "~/scenes/Document/components/SidebarLayout";
@@ -42,7 +42,7 @@ const DocumentSidebarContent = observer(function DocumentSidebarContent({
const isMobile = useMobile();
const inner = (
-
+
}>
diff --git a/app/utils/routeHelpers.ts b/app/utils/routeHelpers.ts
index 3a7519eaa9..5c61a5ae37 100644
--- a/app/utils/routeHelpers.ts
+++ b/app/utils/routeHelpers.ts
@@ -334,15 +334,57 @@ export function desktopify(path: string, origin?: string): string {
export const matchCollectionSlug =
":collectionSlug([0-9a-zA-Z-_~]*-[a-zA-z0-9]{10,15})";
+/** Route matcher for the collection screen. */
+export const matchCollection = `/collection/${matchCollectionSlug}/:tab?`;
+
/** Route matcher for the collection edit screen. */
export const matchCollectionEdit = `/collection/${matchCollectionSlug}/overview/edit`;
+/** Route matcher for creating a new document in a collection. */
+export const matchCollectionNew = `/collection/${matchCollectionSlug}/new`;
+
/** Route matcher for a document slug. */
export const matchDocumentSlug =
":documentSlug([0-9a-zA-Z-_~]*-[a-zA-z0-9]{10,15})";
+/** Route matcher for the document screen. */
+export const matchDocument = `/doc/${matchDocumentSlug}`;
+
/** Route matcher for the document edit screen. */
export const matchDocumentEdit = `/doc/${matchDocumentSlug}/edit`;
/** Route matcher for the document history screen. */
export const matchDocumentHistory = `/doc/${matchDocumentSlug}/history/:revisionId?`;
+
+/** Route matcher for the document shortlink redirect screen. */
+export const matchDocumentShortlink = `/d/${matchDocumentSlug}`;
+
+/** Route matcher for the home screen. */
+export const matchHome = "/home/:tab?";
+
+/** Route matcher for the drafts screen. */
+export const matchDrafts = "/drafts";
+
+/** Route matcher for the archive screen. */
+export const matchArchive = "/archive";
+
+/** Route matcher for the trash screen. */
+export const matchTrash = "/trash";
+
+/** Route matcher for the search screen. */
+export const matchSearch = "/search/:query?";
+
+/** Route matcher for the settings screens. */
+export const matchSettings = "/settings";
+
+/** Route matcher for the debug screen. */
+export const matchDebug = "/debug";
+
+/** Route matcher for the changesets debug screen. */
+export const matchChangesets = `${matchDebug}/changesets`;
+
+/** Route matcher for a publicly shared collection or document. */
+export const matchShare = "/s/:shareId";
+
+/** Route matcher for a document within a public share. */
+export const matchShareDocument = `${matchShare}/doc/${matchDocumentSlug}`;