From e953f28959785bcfc273b8e09946f160d51a7777 Mon Sep 17 00:00:00 2001 From: alexcss Date: Tue, 3 Dec 2024 17:23:44 +0200 Subject: [PATCH] News line --- docusaurus.config.js | 7 +++++- src/components/NewsLine/index.js | 27 ++++++++++++++++++++++ src/components/NewsLine/styles.module.scss | 5 ++++ src/theme/Navbar/Layout/index.js | 7 +++--- 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/components/NewsLine/index.js create mode 100644 src/components/NewsLine/styles.module.scss diff --git a/docusaurus.config.js b/docusaurus.config.js index d89f2262..e5c407a2 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -52,7 +52,12 @@ const config = { description : 'Looking for information we haven’t covered? Fill out the form below to request a new article, and we’ll consider it in future updates.', } }, - } + }, + news: [ + {title: 'Rootstock Hacktivator Program is Live! Contribute and Earn Rewards!', url: 'https://dev.rootstock.io/resources/contribute/hacktivator-program/'}, + {title: 'Contribute and Earn Rewards!', url: '/changelog'}, + {title: 'Rootstock News', url: '/changelog'}, + ] }, // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these. diff --git a/src/components/NewsLine/index.js b/src/components/NewsLine/index.js new file mode 100644 index 00000000..4bcb6b6a --- /dev/null +++ b/src/components/NewsLine/index.js @@ -0,0 +1,27 @@ +import React from "react"; +import clsx from "clsx"; +import styles from './styles.module.scss'; +import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; +import Link from '/src/components/Link' + +export default function NewsLine () { + const {siteConfig} = useDocusaurusContext(); + const news = siteConfig?.customFields?.news || []; + + return news?.length > 0 &&
+
+ {news.map((item, index) => ( + + {item.title} + + ))} +
+ +
+} diff --git a/src/components/NewsLine/styles.module.scss b/src/components/NewsLine/styles.module.scss new file mode 100644 index 00000000..b2474de4 --- /dev/null +++ b/src/components/NewsLine/styles.module.scss @@ -0,0 +1,5 @@ +.NewsLine{ + position: sticky; + top: 88px; + z-index: var(--ifm-z-index-fixed); +} diff --git a/src/theme/Navbar/Layout/index.js b/src/theme/Navbar/Layout/index.js index 8ffbc538..a876c327 100644 --- a/src/theme/Navbar/Layout/index.js +++ b/src/theme/Navbar/Layout/index.js @@ -2,16 +2,14 @@ import React from 'react'; import clsx from 'clsx'; import {ErrorCauseBoundary, useThemeConfig} from '@docusaurus/theme-common'; import { - splitNavbarItems, useHideableNavbar, useNavbarMobileSidebar, } from '@docusaurus/theme-common/internal'; import {translate} from '@docusaurus/Translate'; import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar'; import styles from './styles.module.css'; -import NavbarItem from "@theme/NavbarItem"; import MainNavDesktop from "../MainNavDesktop"; -import useBrokenLinks from "@docusaurus/core/lib/client/exports/useBrokenLinks"; +import NewsLine from '../../../components/NewsLine' function NavbarBackdrop(props) { return ( @@ -28,7 +26,7 @@ export default function NavbarLayout({children}) { } = useThemeConfig(); const mobileSidebar = useNavbarMobileSidebar(); const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll); - + return ( <> + );