diff --git a/docusaurus.config.js b/docusaurus.config.js index 9e353ab..c733da2 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -62,6 +62,12 @@ const config = { theme: { customCss: require.resolve("./src/css/custom.css"), }, + sitemap: { + changefreq: "weekly", + priority: 0.5, + ignorePatterns: ["/tags/**"], + filename: "sitemap.xml", + }, }), ], ], @@ -99,7 +105,7 @@ const config = { label: "Documentation", }, { to: "/blog", label: "Blog", position: "left" }, - { to: "https://status.tjo.space", label: "Status", position: "left" }, + { type: "custom-status-navbar-item", position: "left" }, { type: "localeDropdown", position: "right", diff --git a/package-lock.json b/package-lock.json index e7e329f..54d04b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "dependencies": { "@docusaurus/core": "2.4.1", + "@docusaurus/plugin-sitemap": "^2.4.1", "@docusaurus/preset-classic": "2.4.1", "@easyops-cn/docusaurus-search-local": "^0.36.0", "@mdx-js/react": "^1.6.22", @@ -2340,7 +2341,8 @@ }, "node_modules/@docusaurus/plugin-sitemap": { "version": "2.4.1", - "license": "MIT", + "resolved": "https://registry.npmjs.org/@docusaurus/plugin-sitemap/-/plugin-sitemap-2.4.1.tgz", + "integrity": "sha512-lZx+ijt/+atQ3FVE8FOHV/+X3kuok688OydDXrqKRJyXBJZKgGjA2Qa8RjQ4f27V2woaXhtnyrdPop/+OjVMRg==", "dependencies": { "@docusaurus/core": "2.4.1", "@docusaurus/logger": "2.4.1", diff --git a/package.json b/package.json index d6e492b..2f0762a 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "dependencies": { "@docusaurus/core": "2.4.1", + "@docusaurus/plugin-sitemap": "^2.4.1", "@docusaurus/preset-classic": "2.4.1", "@easyops-cn/docusaurus-search-local": "^0.36.0", "@mdx-js/react": "^1.6.22", diff --git a/src/components/HomepageFeatures/index.tsx b/src/components/HomepageFeatures/index.tsx index 6cb60b5..e1d5b90 100644 --- a/src/components/HomepageFeatures/index.tsx +++ b/src/components/HomepageFeatures/index.tsx @@ -18,7 +18,7 @@ const PrivateServices: ServicesSection = { title: "Private Services", description: ( <> - Services that require tjo.space account. + Services that require id.tjo.space account. ), services: [ diff --git a/src/components/NavbarItems/CustomStatusNavbarItem.tsx b/src/components/NavbarItems/CustomStatusNavbarItem.tsx new file mode 100644 index 0000000..fb5c904 --- /dev/null +++ b/src/components/NavbarItems/CustomStatusNavbarItem.tsx @@ -0,0 +1,45 @@ +import clsx from "clsx"; +import React, { useEffect, useState } from "react"; + +function Healthy({ healthy }) { + if (healthy) return Ok; + + return Issues; +} + +function Mobile({ healthy }) { + return ( +
  • + + Status + +
  • + ); +} + +export default function CustomStatusNavbarItem(props: { + content: string; + mobile?: boolean; +}): JSX.Element | null { + const [healthy, setHealthy] = useState(true); + + useEffect(() => { + fetch( + "https://api.github.com/repos/tjo-space/status/issues?status=open&label=status" + ) + .then((response) => response.json()) + .then((issues) => setHealthy(issues.length === 0)); + }, []); + + if (props.mobile) return ; + + return ( + + Status + + ); +} diff --git a/src/theme/NavbarItem/ComponentTypes.js b/src/theme/NavbarItem/ComponentTypes.js new file mode 100644 index 0000000..999a620 --- /dev/null +++ b/src/theme/NavbarItem/ComponentTypes.js @@ -0,0 +1,25 @@ +import DefaultNavbarItem from "@theme/NavbarItem/DefaultNavbarItem"; +import DropdownNavbarItem from "@theme/NavbarItem/DropdownNavbarItem"; +import LocaleDropdownNavbarItem from "@theme/NavbarItem/LocaleDropdownNavbarItem"; +import SearchNavbarItem from "@theme/NavbarItem/SearchNavbarItem"; +import HtmlNavbarItem from "@theme/NavbarItem/HtmlNavbarItem"; +import DocNavbarItem from "@theme/NavbarItem/DocNavbarItem"; +import DocSidebarNavbarItem from "@theme/NavbarItem/DocSidebarNavbarItem"; +import DocsVersionNavbarItem from "@theme/NavbarItem/DocsVersionNavbarItem"; +import DocsVersionDropdownNavbarItem from "@theme/NavbarItem/DocsVersionDropdownNavbarItem"; +import CustomStatusNavbarItem from "@site/src/components/NavbarItems/CustomStatusNavbarItem"; +const ComponentTypes = { + default: DefaultNavbarItem, + localeDropdown: LocaleDropdownNavbarItem, + search: SearchNavbarItem, + dropdown: DropdownNavbarItem, + html: HtmlNavbarItem, + doc: DocNavbarItem, + docSidebar: DocSidebarNavbarItem, + docsVersion: DocsVersionNavbarItem, + docsVersionDropdown: DocsVersionDropdownNavbarItem, +}; +export default { + ...ComponentTypes, + "custom-status-navbar-item": CustomStatusNavbarItem, +};