Skip to content

Commit

Permalink
Add a link to Times Square docs from sidebar
Browse files Browse the repository at this point in the history
The getDocsUrl function concatenates the given documentation site path
with the configured base URL for the rsp.lsst.io docs.

The link is not styled; this is a proof of concept for dynamically
computing the link.
  • Loading branch information
jonathansick committed Jan 15, 2025
1 parent 3c16913 commit 53b6f01
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/squareone/src/components/TimesSquareApp/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import Link from 'next/link';
import styled from 'styled-components';

import { getDocsUrl } from '../../lib/utils/docsUrls';

const StyledSidebar = styled.div`
border-right: 1px solid var(--rsd-color-primary-600);
padding: 0 var(--size-screen-padding-min) 2rem 0.5rem;
Expand All @@ -21,6 +23,8 @@ const AppTitle = styled.p`
`;

export default function Sidebar({ pageNav, pagePanel }) {
const docsUrl = getDocsUrl('/times-square/');

return (
<StyledSidebar>
<Link href="/times-square">
Expand All @@ -29,6 +33,8 @@ export default function Sidebar({ pageNav, pagePanel }) {
</a>
</Link>

<a href={docsUrl}>Documentation</a>

{pagePanel && pagePanel}

{pageNav && pageNav}
Expand Down
11 changes: 11 additions & 0 deletions apps/squareone/src/lib/utils/docsUrls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import getConfig from 'next/config';

/**
* Get the full URL to a documentation page.
* @param path The path to the documentation page, starting with "/"
* @returns The full URL to the documentation page
*/
export function getDocsUrl(path) {
const { publicRuntimeConfig } = getConfig();
return `${publicRuntimeConfig.docsBaseUrl}${path}`;
}

0 comments on commit 53b6f01

Please sign in to comment.