Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

806 B
Raw Blame
import { useEffect } from "react";
import { useRotatingText } from "./use-text-rotation";

const BRAND_TITLE = "Piik";

export function composeDocumentTitle(
  ...parts: Array<string | null | undefined>
): string {
  const detail = parts.filter((part): part is string => Boolean(part));
  return detail.length > 0
    ? `${BRAND_TITLE} | ${detail.join(" · ")}`
    : BRAND_TITLE;
}

export function useDocumentTitle(
  parts: Array<string | null | undefined>,
  variations: readonly string[],
  context: string,
): string {
  const decoration = useRotatingText(variations, context, { rotate: false });
  const title = composeDocumentTitle(...parts, decoration);
  useEffect(() => {
    document.title = title;
    return () => {
      document.title = BRAND_TITLE;
    };
  }, [title]);
  return title;
}