Skip to content

Commit

Permalink
Merge pull request #344 from vordgi/rd-343
Browse files Browse the repository at this point in the history
rd-343 normalize code style in examples
  • Loading branch information
vordgi authored Oct 16, 2024
2 parents ace088f + 4ebb182 commit e9b182f
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 111 deletions.
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ Read the documentation in a convenient interface at [robindoc.com/docs](https://
Robindoc is a framework for automatically creating documentation websites based on markdown files, built on React.js Server Components.

```tsx filename="app/docs/page.tsx"
export const Documentation = () => {
return (
<RobinProvider>
<Header logo={<Logo />} />
<DocsContainer>
<Sidebar pathname="/docs" />
<Page pathname="/docs" />
</DocsContainer>
<Footer copyright="© 2024 All rights reserved" />
</RobinProvider>
);
};
const DocumentationPage = () => (
<RobinProvider>
<Header logo={<Logo />} />
<DocsContainer>
<Sidebar pathname="/docs" />
<Page pathname="/docs" />
</DocsContainer>
<Footer copyright="© 2024 All rights reserved" />
</RobinProvider>
);
```

The main goal of Robindoc is to create a system where you can fully reuse the existing markdown documentation within your projects.
Expand Down
2 changes: 2 additions & 0 deletions docs/01-getting-started/02-writing-md.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const Page = () => (
}}
/>
);

export default Page;
```

The content of custom components (`children`) will be passed as parsed Markdown.
Expand Down
64 changes: 33 additions & 31 deletions docs/01-getting-started/04-app-organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Robindoc can be considered to consist of several parts:

- Documentation Structure ([more about documentation structure](../02-structure/README.md));
- Robindoc Initialization ([more about initialization](../03-initialization.md));
- Robindoc Initialization ([more about initialization](./03-initialization.md));
- Page Markup and Configuration ([more about customization](../03-customization/README.md));
- Documentation Markdown Files ([more about writing MD](../02-writing-md.md)).
- Documentation Markdown Files ([more about writing MD](./02-writing-md.md)).

## Organizing Documentation Files

Expand All @@ -31,11 +31,13 @@ Next.js supports dynamic routes, so it is recommended to set up one [dynamic seg
```tsx filename="app/docs/[[...path]]/page.tsx"
import { Page, Sidebar, getMeta, getPages } from "../robindoc";

export const Page: React.FC<{ params: { path?: string[] } }> = ({ params }) => {
const Page: React.FC<{ params: { path?: string[] } }> = ({ params }) => {
const pathname = "/docs/" + (params.path?.join("/") || "");

return <Page pathname={pathname} />;
};

export default Page;
```

For more details about the props, refer to the [`Page`](../03-customization/01-elements/page.md) element page.
Expand Down Expand Up @@ -99,18 +101,18 @@ import Logo from "./logo";

import "robindoc/lib/styles.css";

export const Layout: React.FC<React.PropsWithChildren> = ({ children }) => {
return (
<RobinProvider>
<Header logo={<Logo />} />
<DocsContainer>
<Sidebar />
{children}
</DocsContainer>
<Footer copyright="© 2024 All rights reserved" />
</RobinProvider>
);
};
const Layout: React.FC<React.PropsWithChildren> = ({ children }) => (
<RobinProvider>
<Header logo={<Logo />} />
<DocsContainer>
<Sidebar />
{children}
</DocsContainer>
<Footer copyright="© 2024 All rights reserved" />
</RobinProvider>
);

export default Layout;
```

For more details on configuring elements, refer to the [`RobinProvider`](../03-customization/01-elements/robin-provider.md), [`Header`](../03-customization/01-elements/header.md), [`Sidebar`](../03-customization/01-elements/sidebar.md), [`Footer`](../03-customization/01-elements/footer.md), and [`Containers`](../03-customization/01-elements/containers.md) block pages.
Expand All @@ -136,25 +138,25 @@ export const GET = async (request: Request) => {
```

```tsx switcher filename="app/docs/layout.tsx" tab="TypeScript"
export const Layout: React.FC<React.PropsWithChildren> = ({ children }) => {
return (
<RobinProvider>
<Header logo={<Logo />} searcher="/api/search" />
{/* ... */}
</RobinProvider>
);
};
const Layout: React.FC<React.PropsWithChildren> = ({ children }) => (
<RobinProvider>
<Header logo={<Logo />} searcher="/api/search" />
{/* ... */}
</RobinProvider>
);

export default Layout;
```

```js switcher filename="app/docs/layout.js" tab="JavaScript"
export const Layout: React.FC<React.PropsWithChildren> = ({ children }) => {
return (
<RobinProvider>
<Header logo={<Logo />} searcher="/api/search" />
{/* ... */}
</RobinProvider>
);
};
const Layout = ({ children }) => (
<RobinProvider>
<Header logo={<Logo />} searcher="/api/search" />
{/* ... */}
</RobinProvider>
);

export default Layout;
```

### Vercel
Expand Down
6 changes: 6 additions & 0 deletions docs/03-customization/01-elements/containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ A special container designed for custom pages
import { PageContainer } from "robindoc";

const HomePage = () => <PageContainer>{/* ... */}</PageContainer>;

export default HomePage;
```

## DocsContainer
Expand All @@ -22,6 +24,8 @@ import { DocsContainer } from "robindoc";
const DocsLayout: React.FC<React.PropsWithChildren> = ({ children }) => (
<DocsContainer>{children}</DocsContainer>;
);

export default DocsLayout;
```

## BlogContainer
Expand All @@ -36,6 +40,8 @@ import { BlogContainer } from "robindoc";
const BlogLayout: React.FC<React.PropsWithChildren> = ({ children }) => (
<BlogContainer>{children}</BlogContainer>;
);

export default BlogLayout;
```

## Usage
Expand Down
16 changes: 8 additions & 8 deletions docs/03-customization/01-elements/footer.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
```tsx filename="app/layout.tsx"
import { RobinProvider, Footer } from "robindoc";

export const Layout: React.FC<React.PropsWithChildren> = ({ children }) => {
return (
<RobinProvider>
{/* ... */}
<Footer copyright="© 2024 All rights reserved" />
</RobinProvider>
);
};
const Layout: React.FC<React.PropsWithChildren> = ({ children }) => (
<RobinProvider>
{/* ... */}
<Footer copyright="© 2024 All rights reserved" />
</RobinProvider>
);

export default Layout;
```

## Props
Expand Down
16 changes: 8 additions & 8 deletions docs/03-customization/01-elements/header.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
```tsx filename="app/layout.tsx"
import { RobinProvider, Header } from "robindoc";

export const Layout: React.FC<React.PropsWithChildren> = ({ children }) => {
return (
<RobinProvider>
<Header logo={<Logo />} />
{/* ... */}
</RobinProvider>
);
};
const Layout: React.FC<React.PropsWithChildren> = ({ children }) => (
<RobinProvider>
<Header logo={<Logo />} />
{/* ... */}
</RobinProvider>
);

export default Layout;
```

## Props
Expand Down
18 changes: 9 additions & 9 deletions docs/03-customization/01-elements/keylinks.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const RootLayout: React.FC<React.PropsWithChildren> = ({ children }) => (
</body>
</html>
);

export default RootLayout;
```

<Note>
Expand All @@ -46,15 +48,13 @@ import { DocsContainer, KeylinkToNavigation } from "robindoc";

import { Sidebar } from "./robindoc";

const DocsLayout: React.FC<React.PropsWithChildren> = ({ children }) => {
return (
<DocsContainer>
<Sidebar />
{children}
<KeylinkToNavigation />
</DocsContainer>
);
};
const DocsLayout: React.FC<React.PropsWithChildren> = ({ children }) => (
<DocsContainer>
<Sidebar />
{children}
<KeylinkToNavigation />
</DocsContainer>
);

export default DocsLayout;
```
Expand Down
20 changes: 10 additions & 10 deletions docs/03-customization/01-elements/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
```tsx filename="app/docs/example/page.tsx"
import { Page } from "./robindoc";

export const Page = ({ children }) => {
return (
<Page
pathname="/docs/example"
components={{
Example: ({ children }) => <span>{children}</span>,
}}
/>
);
};
const Page = ({ children }) => (
<Page
pathname="/docs/example"
components={{
Example: ({ children }) => <span>{children}</span>,
}}
/>
);

export default Page;
```

## Props
Expand Down
8 changes: 5 additions & 3 deletions docs/03-customization/01-elements/robin-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
```tsx filename="app/layout.tsx"
import { RobinProvider } from "robindoc";

export const Layout: React.FC<React.PropsWithChildren> = ({ children }) => {
return <RobinProvider>{/* ... */}</RobinProvider>;
};
const Layout: React.FC<React.PropsWithChildren> = ({ children }) => (
<RobinProvider>{/* ... */}</RobinProvider>;
);

export default Layout;
```

## Usage
Expand Down
16 changes: 8 additions & 8 deletions docs/03-customization/01-elements/sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
```tsx filename="app/docs/layout.tsx"
import { Sidebar } from "./robindoc";

const DocsLayout: React.FC<React.PropsWithChildren> = ({ children }) => {
return (
<DocsContainer>
<Sidebar />
{children}
</DocsContainer>
);
};
const DocsLayout: React.FC<React.PropsWithChildren> = ({ children }) => (
<DocsContainer>
<Sidebar />
{children}
</DocsContainer>
);

export default DocsLayout;
```

## Props
Expand Down
16 changes: 7 additions & 9 deletions docs/03-customization/03-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ Here’s an example of how to configure the `Header` component with a search API
```tsx filename="app/layout.tsx"
import { RobinProvider, Header } from "robindoc";

export const Layout: React.FC<React.PropsWithChildren> = ({ children }) => {
return (
<RobinProvider>
<Header logo={<Logo />} searcher="/api/search" />
{/* ... */}
</RobinProvider>
);
};
const Layout: React.FC<React.PropsWithChildren> = ({ children }) => (
<RobinProvider>
<Header logo={<Logo />} searcher="/api/search" />
{/* ... */}
</RobinProvider>
);
```

## Client-Side Callback
Expand All @@ -34,7 +32,7 @@ Here’s an example callback function:
```ts filename="utils/searcher.ts"
import { type Searcher } from "robindoc/lib/core/types/search";

const searcher: Searcher = async (search, abortController) => {
export const searcher: Searcher = async (search, abortController) => {
const results = await advancedSearcher(pagesData, search, abortController);
return results;
};
Expand Down
24 changes: 12 additions & 12 deletions docs/03-customization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import { RobinProvider, Header, Footer, DocsContainer } from "robindoc";
import { Page, Sidebar } from "./robindoc";
import "robindoc/lib/styles.css";

export const Documentation = () => {
return (
<RobinProvider>
<Header logo={<Logo />} />
<DocsContainer>
<Sidebar pathname="/docs" />
<Page pathname="/docs" />
</DocsContainer>
<Footer copyright="© 2024 All rights reserved" />
</RobinProvider>
);
};
const DocumentationPage = () => (
<RobinProvider>
<Header logo={<Logo />} />
<DocsContainer>
<Sidebar pathname="/docs" />
<Page pathname="/docs" />
</DocsContainer>
<Footer copyright="© 2024 All rights reserved" />
</RobinProvider>
);

export default DocumentationPage;
```

Framework-based logic configuration - search API route, and the current page path - is up to you. For more details, read the [App Organization](../01-getting-started/04-app-organization.md) page.
Expand Down
2 changes: 1 addition & 1 deletion packages/robindoc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "robindoc",
"version": "2.1.5",
"version": "2.1.6",
"description": "",
"main": "./lib/index.js",
"scripts": {
Expand Down

0 comments on commit e9b182f

Please sign in to comment.