Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): add announcement config in docs.yml #4568

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ navigation:
- page: Navigation
icon: fa-regular fa-compass
path: ./pages/docs/building-your-docs/navigation.mdx
- page: Announcement Banner
icon: fa-regular fa-bullhorn
path: ./pages/docs/building-your-docs/announcement-banner.mdx
- page: Links and Redirects
icon: fa-regular fa-link
path: ./pages/docs/building-your-docs/links-and-redirects.mdx
Expand Down
14 changes: 14 additions & 0 deletions fern/pages/docs/building-your-docs/announcement-banner.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Add an announcement banner to your docs
subtitle: Prominently highlight new features, updates, or important information
slug: /docs/building-your-docs/announcements
---

An announcement banner is a great way to draw attention to new features and product launches. When configured, the announcement bar appears at the top of your docs site. After the user dismisses the bar, it will reappear the next time you update the announcement.

```yaml docs.yml
announcement:
message: "🚀 New feature: Announcements are available! (<a href=\"https://buildwithfern.com/learn/docs/building-your-docs/announcements\" target=\"_blank\">Learn more</a>) 🚀"
```

Markdown and HTML is supported in the announcement message. You can include links, images, and other formatting. [Custom css](/learn/docs/building-your-docs/custom-css-global-js#custom-css) can be used to customize the style of the announcement.
8 changes: 8 additions & 0 deletions packages/cli/configuration/fern/definition/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ types:
The `analytics` object allows you to configure analytics for your docs site.
Currently, only Segment is supported.

announcement: optional<AnnouncementConfig>

# navigation
tabs: optional<map<TabId, TabConfig>>
versions: optional<list<VersionConfig>>
Expand Down Expand Up @@ -975,3 +977,9 @@ types:
PlaygroundButtonSettings:
properties:
href: optional<string>

AnnouncementConfig:
properties:
message:
type: string
docs: The message to display in the announcement bar. Markdown is supported.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FernRegistry as CjsFdrSdk } from "@fern-fern/fdr-cjs-sdk";
import { Audiences } from "../commons";
import { WithoutQuestionMarks } from "../commons/WithoutQuestionMarks";
import { DocsInstance, ExperimentalConfig, PlaygroundSettings, VersionAvailability } from "./schemas";
import { AnnouncementConfig } from "./schemas/sdk/api/resources/docs/types/AnnouncementConfig";

export interface ParsedDocsConfiguration {
instances: DocsInstance[];
Expand Down Expand Up @@ -30,6 +31,7 @@ export interface ParsedDocsConfiguration {
layout: WithoutQuestionMarks<CjsFdrSdk.docs.v1.commons.DocsLayoutConfig> | undefined;
defaultLanguage: CjsFdrSdk.docs.v1.commons.ProgrammingLanguage | undefined;
analyticsConfig: CjsFdrSdk.docs.v1.commons.AnalyticsConfig | undefined;
announcement: AnnouncementConfig | undefined;

/* integrations */
integrations: CjsFdrSdk.docs.v1.commons.IntegrationsConfig | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export async function parseDocsConfiguration({
navbarLinks: convertNavbarLinks(navbarLinks),
footerLinks: convertFooterLinks(footerLinks),
defaultLanguage,
announcement: rawDocsConfiguration.announcement,

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

export interface AnnouncementConfig {
/** The message to display in the announcement bar. Markdown is supported. */
message: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface DocsConfiguration {
* Currently, only Segment is supported.
*/
analytics?: FernDocsConfig.AnalyticsConfig;
announcement?: FernDocsConfig.AnnouncementConfig;
tabs?: Record<FernDocsConfig.TabId, FernDocsConfig.TabConfig>;
versions?: FernDocsConfig.VersionConfig[];
landingPage?: FernDocsConfig.PageConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ export * from "./IntegrationsConfig";
export * from "./ExperimentalConfig";
export * from "./PlaygroundSettings";
export * from "./PlaygroundButtonSettings";
export * from "./AnnouncementConfig";
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 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 AnnouncementConfig: core.serialization.ObjectSchema<
serializers.AnnouncementConfig.Raw,
FernDocsConfig.AnnouncementConfig
> = core.serialization.object({
message: core.serialization.string(),
});

export declare namespace AnnouncementConfig {
interface Raw {
message: string;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const DocsConfiguration: core.serialization.ObjectSchema<
),
title: core.serialization.string().optional(),
analytics: core.serialization.lazyObject(async () => (await import("../../..")).AnalyticsConfig).optional(),
announcement: core.serialization.lazyObject(async () => (await import("../../..")).AnnouncementConfig).optional(),
tabs: core.serialization
.record(
core.serialization.lazy(async () => (await import("../../..")).TabId),
Expand Down Expand Up @@ -65,6 +66,7 @@ export declare namespace DocsConfiguration {
instances: serializers.DocsInstance.Raw[];
title?: string | null;
analytics?: serializers.AnalyticsConfig.Raw | null;
announcement?: serializers.AnnouncementConfig.Raw | null;
tabs?: Record<serializers.TabId.Raw, serializers.TabConfig.Raw> | null;
versions?: serializers.VersionConfig.Raw[] | null;
"landing-page"?: serializers.PageConfiguration.Raw | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ export * from "./IntegrationsConfig";
export * from "./ExperimentalConfig";
export * from "./PlaygroundSettings";
export * from "./PlaygroundButtonSettings";
export * from "./AnnouncementConfig";
4 changes: 2 additions & 2 deletions packages/cli/docs-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@fern-api/docs-resolver": "workspace:*",
"@fern-api/fdr-sdk": "0.107.0-09e88f5f9",
"@fern-api/fdr-sdk": "0.107.0-58bab3016",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-sdk": "workspace:*",
"@fern-api/logger": "workspace:*",
Expand Down Expand Up @@ -62,4 +62,4 @@
"typescript": "4.6.4",
"vitest": "^2.0.5"
}
}
}
4 changes: 2 additions & 2 deletions packages/cli/docs-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@fern-api/configuration": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-api/docs-markdown-utils": "workspace:*",
"@fern-api/fdr-sdk": "0.107.0-09e88f5f9",
"@fern-api/fdr-sdk": "0.107.0-58bab3016",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-generator": "workspace:*",
"@fern-api/ir-sdk": "workspace:*",
Expand All @@ -53,4 +53,4 @@
"typescript": "4.6.4",
"vitest": "^2.0.5"
}
}
}
4 changes: 4 additions & 0 deletions packages/cli/docs-resolver/src/DocsDefinitionResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ export class DocsDefinitionResolver {
footerLinks: this.parsedDocsConfig.footerLinks,
defaultLanguage: this.parsedDocsConfig.defaultLanguage,
analyticsConfig: this.parsedDocsConfig.analyticsConfig,
announcement:
this.parsedDocsConfig.announcement != null
? { text: this.parsedDocsConfig.announcement.message }
: undefined,
// deprecated
logo: undefined,
logoV2: undefined,
Expand Down
16 changes: 9 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading