Skip to content

Commit

Permalink
feat: header tabs (#4124)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Jul 26, 2024
1 parent 0fe609a commit c03f8df
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 31 deletions.
16 changes: 13 additions & 3 deletions packages/cli/configuration/fern/definition/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ types:
- `{number}px`
searchbar-placement:
type: optional<SidebarOrHeaderPlacement>
type: optional<SearchbarPlacement>
docs: |
Sets the placement of the searchbar
Expand All @@ -278,7 +278,7 @@ types:
Note: this setting is ignored when `disable-header` is set to true.
tabs-placement:
type: optional<SidebarOrHeaderPlacement>
type: optional<TabsPlacement>
docs: |
Set the placement of the tabs
Expand Down Expand Up @@ -313,7 +313,17 @@ types:
If `disable-header` is set to true, the header will not be rendered. Instead, the logo will be rendered as part of the sidebar,
and a 1px border will separate the sidebar from the content.
SidebarOrHeaderPlacement:
SearchbarPlacement:
enum:
- header
- value: header-tabs
name: header_tabs
docs: |
The searchbar will be placed in the header, but on the tabs row. If the tabs row is hidden, the searchbar will be placed in the header instead.
This is a good option if you want to keep the searchbar visible, but save space in the header for more navbar links.
- sidebar

TabsPlacement:
enum:
- header
- sidebar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ function convertLayoutConfig(layout: RawDocs.LayoutConfig | undefined): ParsedDo
searchbarPlacement:
layout.searchbarPlacement === "header"
? DocsV1Write.SearchbarPlacement.Header
: layout.searchbarPlacement === "header-tabs"
? DocsV1Write.SearchbarPlacement.HeaderTabs
: DocsV1Write.SearchbarPlacement.Sidebar,
tabsPlacement:
layout.tabsPlacement === "header" ? DocsV1Write.TabsPlacement.Header : DocsV1Write.TabsPlacement.Sidebar,
Expand Down Expand Up @@ -664,7 +666,8 @@ function parsePageConfig(
slug: item.slug,
icon: item.icon,
hidden: item.hidden,
noindex: item.noindex
// TODO: implement noindex
noindex: undefined
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ export interface LayoutConfig {
*
* Note: this setting is ignored when `disable-header` is set to true.
*/
searchbarPlacement?: FernDocsConfig.SidebarOrHeaderPlacement;
searchbarPlacement?: FernDocsConfig.SearchbarPlacement;
/**
* Set the placement of the tabs
*
* @default: `sidebar`
*
* Note: this setting is ignored when `disable-header` is set to true.
*/
tabsPlacement?: FernDocsConfig.SidebarOrHeaderPlacement;
tabsPlacement?: FernDocsConfig.TabsPlacement;
/**
* Set the alignment of the mardown content.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ export interface PageConfiguration {
slug?: string;
icon?: string;
hidden?: boolean;
noindex?: boolean;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export type SearchbarPlacement =
| "header"
/**
* The searchbar will be placed in the header, but on the tabs row. If the tabs row is hidden, the searchbar will be placed in the header instead.
* This is a good option if you want to keep the searchbar visible, but save space in the header for more navbar links. */
| "header-tabs"
| "sidebar";

export const SearchbarPlacement = {
Header: "header",
HeaderTabs: "header-tabs",
Sidebar: "sidebar",
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* This file was auto-generated by Fern from our API Definition.
*/

export type SidebarOrHeaderPlacement = "header" | "sidebar";
export type TabsPlacement = "header" | "sidebar";

export const SidebarOrHeaderPlacement = {
export const TabsPlacement = {
Header: "header",
Sidebar: "sidebar",
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export * from "./BackgroundImageConfiguration";
export * from "./BackgroundImageThemedConfig";
export * from "./DocsTypographyConfig";
export * from "./LayoutConfig";
export * from "./SidebarOrHeaderPlacement";
export * from "./SearchbarPlacement";
export * from "./TabsPlacement";
export * from "./ContentAlignment";
export * from "./HeaderPosition";
export * from "./FontConfig";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export const LayoutConfig: core.serialization.ObjectSchema<serializers.LayoutCon
headerHeight: core.serialization.property("header-height", core.serialization.string().optional()),
searchbarPlacement: core.serialization.property(
"searchbar-placement",
core.serialization.lazy(async () => (await import("../../..")).SidebarOrHeaderPlacement).optional()
core.serialization.lazy(async () => (await import("../../..")).SearchbarPlacement).optional()
),
tabsPlacement: core.serialization.property(
"tabs-placement",
core.serialization.lazy(async () => (await import("../../..")).SidebarOrHeaderPlacement).optional()
core.serialization.lazy(async () => (await import("../../..")).TabsPlacement).optional()
),
contentAlignment: core.serialization.property(
"content-alignment",
Expand All @@ -37,8 +37,8 @@ export declare namespace LayoutConfig {
"content-width"?: string | null;
"sidebar-width"?: string | null;
"header-height"?: string | null;
"searchbar-placement"?: serializers.SidebarOrHeaderPlacement.Raw | null;
"tabs-placement"?: serializers.SidebarOrHeaderPlacement.Raw | null;
"searchbar-placement"?: serializers.SearchbarPlacement.Raw | null;
"tabs-placement"?: serializers.TabsPlacement.Raw | null;
"content-alignment"?: serializers.ContentAlignment.Raw | null;
"header-position"?: serializers.HeaderPosition.Raw | null;
"disable-header"?: boolean | null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as serializers from "../../..";
import * as FernDocsConfig from "../../../../api";
import * as core from "../../../../core";

export const SearchbarPlacement: core.serialization.Schema<
serializers.SearchbarPlacement.Raw,
FernDocsConfig.SearchbarPlacement
> = core.serialization.enum_(["header", "header-tabs", "sidebar"]);

export declare namespace SearchbarPlacement {
type Raw = "header" | "header-tabs" | "sidebar";
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as serializers from "../../..";
import * as FernDocsConfig from "../../../../api";
import * as core from "../../../../core";

export const TabsPlacement: core.serialization.Schema<serializers.TabsPlacement.Raw, FernDocsConfig.TabsPlacement> =
core.serialization.enum_(["header", "sidebar"]);

export declare namespace TabsPlacement {
type Raw = "header" | "sidebar";
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export * from "./BackgroundImageConfiguration";
export * from "./BackgroundImageThemedConfig";
export * from "./DocsTypographyConfig";
export * from "./LayoutConfig";
export * from "./SidebarOrHeaderPlacement";
export * from "./SearchbarPlacement";
export * from "./TabsPlacement";
export * from "./ContentAlignment";
export * from "./HeaderPosition";
export * from "./FontConfig";
Expand Down

0 comments on commit c03f8df

Please sign in to comment.