Skip to content

Commit

Permalink
theme types
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubabrzy committed Sep 20, 2023
1 parent 9b35139 commit a289521
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 19 deletions.
9 changes: 8 additions & 1 deletion src/theme/BlogLastPost/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ import React from "react";
import PatternBg from "@site/src/components/PatternBg";
import Button from "@site/src/components/Button";
import Link from "@docusaurus/Link";
import { PropBlogPostContent } from "@docusaurus/plugin-content-blog";

export default function BlogLastPost({ item }) {
type BlogLastPostProps = {
item: {
content: PropBlogPostContent;
};
};

export default function BlogLastPost({ item }: BlogLastPostProps) {
const { permalink, title, date, formattedDate, description } =
item.content.metadata;

Expand Down
3 changes: 2 additions & 1 deletion src/theme/BlogLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";

import Layout from "@theme/Layout";
import { Props } from "@theme/BlogLayout";

export default function BlogLayout(props) {
export default function BlogLayout(props: Props) {
const { children, ...layoutProps } = props;

return (
Expand Down
9 changes: 8 additions & 1 deletion src/theme/BlogListItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import Link from "@docusaurus/Link";
import Button from "@site/src/components/Button";
import React from "react";
import { PropBlogPostContent } from "@docusaurus/plugin-content-blog";

export default function BlogListItem({ item }) {
type BlogListItemProps = {
item: {
content: PropBlogPostContent;
};
};

export default function BlogListItem({ item }: BlogListItemProps) {
const { permalink, title, date, formattedDate, description } =
item.content.metadata;

Expand Down
10 changes: 9 additions & 1 deletion src/theme/BlogListItems/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import React from "react";

import BlogListItem from "@theme/BlogListItem";
export default function BlogListItems({ items }) {
import { PropBlogPostContent } from "@docusaurus/plugin-content-blog";

type BlogListItemsProps = {
items: readonly {
content: PropBlogPostContent;
}[];
};

export default function BlogListItems({ items }: BlogListItemsProps) {
return (
<div className="max-w-7xl mx-auto grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-x-6 gap-y-12 py-4 md:py-10 px-4">
{items.map((item) => (
Expand Down
3 changes: 2 additions & 1 deletion src/theme/BlogListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import BlogListPaginator from "@theme/BlogListPaginator";
import SearchMetadata from "@theme/SearchMetadata";
import BlogListItems from "@theme/BlogListItems";
import BlogLastPost from "@theme/BlogLastPost";
import { Props } from "@theme/BlogListPage";

export default function BlogListPage(props) {
export default function BlogListPage(props: Props) {
const { metadata, items } = props;

const { blogDescription, blogTitle } = metadata;
Expand Down
4 changes: 3 additions & 1 deletion src/theme/BlogListPaginator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from "react";

import Button from "@site/src/components/Button";
export default function BlogListPaginator(props) {
import { Props } from "@theme/BlogListPaginator";

export default function BlogListPaginator(props: Props) {
const { metadata } = props;
const { previousPage, nextPage } = metadata;
return (
Expand Down
3 changes: 2 additions & 1 deletion src/theme/BlogPostItem/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { blogPostContainerID } from "@docusaurus/utils-common";
import { useBlogPost } from "@docusaurus/theme-common/internal";
import MDXContent from "@theme/MDXContent";
import TextContent from "@site/src/components/TextContent";
import { Props } from "@theme/BlogPostItem/Content";

export default function BlogPostItemContent({ children }) {
export default function BlogPostItemContent({ children }: Props) {
const { isBlogPostPage } = useBlogPost();
return (
<TextContent
Expand Down
12 changes: 7 additions & 5 deletions src/theme/DocBreadcrumbs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import Link from "@docusaurus/Link";

import HomeBreadcrumbItem from "@theme/DocBreadcrumbs/Items/Home";

type BreadcrumbsItemLinkProps = {
children: ReactNode;
href: string | undefined;
isLast: boolean;
};

function BreadcrumbsItemLink({
children,
href,
isLast,
}: {
children: ReactNode;
href: string | undefined;
isLast: boolean;
}) {
}: BreadcrumbsItemLinkProps) {
if (isLast) {
return (
<span className="text-gray-600 dark:text-gray-500" itemProp="name">
Expand Down
3 changes: 2 additions & 1 deletion src/theme/DocItem/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import MDXContent from "@theme/MDXContent";
import TextContent from "@site/src/components/TextContent";
import { Props } from "@theme/DocItem/Content";

export default function DocItemContent({ children }) {
export default function DocItemContent({ children }: Props) {
return (
<TextContent className="max-w-none">
<MDXContent>{children}</MDXContent>
Expand Down
8 changes: 6 additions & 2 deletions src/theme/DocPage/Layout/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ export default function DocPageLayoutSidebar({
sidebar,
}: SidebarProps) {
const { pathname } = useLocation();

return (
<aside className={className}>
<ResetOnSidebarChange>
<div className="p-2 xl:p-4 text-sm xl:text-base w-full sticky top-0">
<DocSidebar sidebar={sidebar} path={pathname} />
<DocSidebar
sidebar={sidebar}
path={pathname}
isHidden={false}
onCollapse={() => {}}
/>
</div>
</ResetOnSidebarChange>
</aside>
Expand Down
2 changes: 1 addition & 1 deletion src/theme/DocPage/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";
import DocPageLayoutSidebar from "./Sidebar";
import { useDocsSidebar } from "@docusaurus/theme-common/internal";
import Layout from "@theme/Layout";
import BackToTopButton from "@theme/BackToTopButton";
import DocPageLayoutSidebar from "@theme/DocPage/Layout/Sidebar";
import type { Props } from "@theme/DocPage/Layout";

export default function DocPageLayout({ children }: Props) {
Expand Down
9 changes: 7 additions & 2 deletions src/theme/DocPaginator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ export default function DocPaginator(props: Props) {
const { previous, next } = props;
return (
<nav className="grid grid-cols-2 gap-3" aria-label="Docs pages">
{previous && <PaginatorNavLink {...previous} subLabel="Previous" />}
{previous && (
<PaginatorNavLink
{...previous}
subLabel={<>Previous</>}
/>
)}
{next && (
<PaginatorNavLink
{...next}
subLabel="Next"
subLabel={<>Next</>}
isNext
className="col-start-2"
/>
Expand Down
3 changes: 2 additions & 1 deletion src/theme/PaginatorNavLink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ type PaginatorNavLink = Props & {
className?: string;
};

export default function PaginatorNavLink(props: Props) {
export default function PaginatorNavLink(props: PaginatorNavLink) {
const { permalink, title, subLabel, isNext, className } = props;

return (
<Link
className={clsx(
Expand Down

0 comments on commit a289521

Please sign in to comment.