Skip to content

Commit

Permalink
Merge pull request #475 from player-ui/docsite-fixes
Browse files Browse the repository at this point in the history
Docsite Fixes
  • Loading branch information
mercillo authored Aug 4, 2024
2 parents c6ced91 + ac4b79a commit 3a7d95f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 87 deletions.
1 change: 0 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@bazel_gazelle//:def.bzl", "gazelle_binary", "gazelle")
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")

package(default_visibility = ["//visibility:public"])

Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ bazel_dep(name = "rules_player")

archive_override(
module_name = "rules_player",
strip_prefix = "rules_player-1.1.2",
urls = ["https://github.com/player-ui/rules_player/archive/refs/tags/v1.1.2.tar.gz"],
integrity = "sha256-7aroW0aRlDpr5tOKVloMANRaLvt6xOiDVxESrSy0t58="
strip_prefix = "rules_player-1.1.3",
urls = ["https://github.com/player-ui/rules_player/archive/refs/tags/v1.1.3.tar.gz"],
integrity = "sha256-Fqe4Y9aY5R0Y2yL9k+fsNKDrNPFP5/utyS5DQaoeYBA="
)
#local_path_override(module_name = "rules_player", path = "../rules_player")

Expand Down
2 changes: 1 addition & 1 deletion docs/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("@rules_player//distribution/tar:defs.bzl", "stamp_tar_files")
load("@rules_player//gh-pages:defs.bzl","gh_pages")

Expand Down Expand Up @@ -30,6 +29,7 @@ stamp_tar_files(
"DOCS_BASE_PATH": "{STABLE_DOCS_BASE_PATH}",
"ALGOLIA_SEARCH_API_KEY": "{STABLE_ALGOLIA_SEARCH_API_KEY}",
},
stable = True
)

genrule(
Expand Down
9 changes: 5 additions & 4 deletions docs/site/components/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// import path from "path-browserify";
import path from "path-browserify";
import { BASE_PREFIX } from "../config/constants";

export function withBasePrefix(location?: string): string | undefined {
if (!location) {
return location;
}

// if (process.env.NEXT_PUBLIC_BASE_PATH) {
// return path.join(process.env.NEXT_PUBLIC_BASE_PATH, location);
// }
if (BASE_PREFIX) {
return path.join("/", BASE_PREFIX, location);
}

return location;
}
18 changes: 8 additions & 10 deletions docs/site/components/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Link, useLocation, useNavigate } from "react-router-dom";
import { Link, useLocation } from "react-router-dom";
import {
Flex,
Image,
Expand All @@ -10,7 +10,6 @@ import {
Icon,
Link as CLink,
IconButton,
chakra,
Drawer,
Heading,
Text,
Expand All @@ -27,7 +26,7 @@ import { HamburgerIcon } from "@chakra-ui/icons";
import type { Route } from "../config/navigation";
import NAV, { PATH_TO_NAV, Platform } from "../config/navigation";
import { ColorSchemeSwitch } from "./ColorSchemeSwitch";
import { DOCS_BASE_URL, GITHUB_URL } from "../config/constants";
import { DOCS_BASE_URL, GITHUB_URL, BASE_PREFIX } from "../config/constants";
import { withBasePrefix } from "./Image";
import { SearchInput } from "./Search";
import { GithubIcon } from "./gh-icon";
Expand Down Expand Up @@ -120,7 +119,7 @@ const SideNavigationList = (props: { route: Route }) => {
);
};

export const SideNavigation = () => {
export const SideNavigation = (): React.JSX.Element | null => {
const { pathname } = useLocation();
const subRoutes = PATH_TO_NAV.get(pathname);

Expand All @@ -141,7 +140,7 @@ export const Footer = () => {
return null;
};

export const GitHubButton = () => {
export const GitHubButton = (): React.JSX.Element => {
return (
<Link aria-label="Go to our GitHub page" to={GITHUB_URL}>
<IconButton
Expand Down Expand Up @@ -192,9 +191,8 @@ const useGetReleasedVersions = () => {
return releasedVersions;
};

export const VersionSelector = () => {
export const VersionSelector = (): React.JSX.Element => {
const location = useLocation();
const navigate = useNavigate();
const released = useGetReleasedVersions();

return (
Expand All @@ -206,9 +204,9 @@ export const VersionSelector = () => {
display: "flex",
flexShrink: "0",
}}
value={location.pathname || "/latest"}
value={BASE_PREFIX || "latest"}
onChange={(e) => {
navigate(`${DOCS_BASE_URL}/${e.target.value}`);
window.location.href = `${DOCS_BASE_URL}${e.target.value}/#${location.pathname}`;
}}
>
<option value="latest">Latest</option>
Expand All @@ -222,7 +220,7 @@ export const VersionSelector = () => {
);
};

export const TopNavigation = () => {
export const TopNavigation = (): React.JSX.Element => {
const { pathname, search } = useLocation();
const subRoutes = PATH_TO_NAV.get(pathname);
const mobileNavDisclosure = useDisclosure();
Expand Down
7 changes: 5 additions & 2 deletions docs/site/config/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export const GITHUB_URL = 'https://github.com/player-ui/player';
export const DOCS_BASE_URL = 'https://player-ui.github.io/';
export const GITHUB_URL = "https://github.com/player-ui/player";
export const DOCS_BASE_URL = "https://player-ui.github.io/";

export const BASE_PREFIX: string | undefined =
process.env.NODE_ENV === "production" ? "DOCS_BASE_PATH" : undefined;
62 changes: 0 additions & 62 deletions docs/site/next.config.mjs

This file was deleted.

4 changes: 0 additions & 4 deletions docs/site/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import fs from "fs";

const __dirname = new URL(".", import.meta.url).pathname;

// This will be replaced during the build stamping
export const BASE_PREFIX =
process.env.NODE_ENV === "production" ? "/DOCS_BASE_PATH" : undefined;

const findPageRoutes = (searchPath = "./pages") => {
const files = fs.readdirSync(searchPath);
const routes: string[] = [];
Expand Down

0 comments on commit 3a7d95f

Please sign in to comment.