Files
radicle-explorer/src/views/projects
Thomas Scholtes 283b665b31 Switch to flat project route type
We switch to a project route type that is just a union. This has the
following advantages

* It’s much easier to construct project routes. Fewer properties are
  needed and there are no nested objects.
* We eliminate the implicitly shared properties `path`, `peer`,
  `revision` and `route` which only belonged to the tree route.
* The structure of the project route is more regular and thus easier to
  understand.

Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
2023-07-17 11:27:57 +02:00
..
2023-07-17 11:27:57 +02:00
2023-07-17 11:27:57 +02:00
2023-07-17 11:27:57 +02:00
2023-07-17 11:27:57 +02:00
2023-07-17 11:27:57 +02:00
2023-06-06 10:07:50 +02:00
2023-07-17 11:27:57 +02:00
2023-07-17 11:27:57 +02:00
2023-07-17 11:27:57 +02:00
2023-07-17 11:27:57 +02:00
2023-07-12 15:59:46 +02:00

<script lang="ts">
  import type { BaseUrl } from "@httpd-client";

  import Markdown from "@app/components/Markdown.svelte";
  import { routeToPath } from "@app/lib/router";

  export let projectId: string;
  export let peer: string | undefined;
  export let baseUrl: BaseUrl;
  export let revision: string | undefined;
  export let content: string;
  export let path: string;
  export let rawPath: string;

  let linkBaseUrl: string | undefined;

  $: {
    if (!path || path === "/") {
      // For the default root path, the `tree/<revision>` portion is omitted
      // from the URL. This means that links cannot be resolved with respect
      // to the current location. To work around this we provide path that
      // results a fully expanded URL with which we can resolve all links in the
      // Markdown.
      linkBaseUrl = new URL(
        routeToPath({
          resource: "project.tree",
          project: projectId,
          seed: baseUrl,
          peer,
          revision,
          path: "README.md",
        }),
        window.origin,
      ).href;
    } else {
      linkBaseUrl = undefined;
    }
  }
</script>

<style>
  article {
    padding: 2rem;
    width: 100%;
    background: var(--color-background-1);
    border-bottom-left-radius: var(--border-radius-small);
    border-bottom-right-radius: var(--border-radius-small);
  }
</style>

<article>
  <Markdown {linkBaseUrl} {content} {rawPath} {path} />
</article>