@farming-labs/theme 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
2
  import * as react_jsx_runtime0 from "react/jsx-runtime";
3
- import { DocsConfig } from "@farming-labs/docs";
3
+ import { DocsConfig, PageFrontmatter } from "@farming-labs/docs";
4
4
 
5
5
  //#region src/docs-layout.d.ts
6
6
  /**
@@ -16,23 +16,19 @@ import { DocsConfig } from "@farming-labs/docs";
16
16
  */
17
17
  declare function createDocsMetadata(config: DocsConfig): Record<string, unknown>;
18
18
  /**
19
- * Generate page-level metadata with dynamic OG images.
19
+ * Generate page-level metadata with dynamic or static OG/twitter.
20
+ * When the page has `openGraph` or `twitter` in frontmatter, those are used (static OG).
21
+ * Otherwise uses `ogImage` or the config dynamic endpoint.
20
22
  *
21
23
  * Usage in a docs page or [[...slug]] route:
22
24
  * ```ts
23
25
  * export function generateMetadata({ params }) {
24
26
  * const page = getPage(params.slug);
25
- * return createPageMetadata(docsConfig, {
26
- * title: page.data.title,
27
- * description: page.data.description,
28
- * });
27
+ * return createPageMetadata(docsConfig, page.data);
29
28
  * }
30
29
  * ```
31
30
  */
32
- declare function createPageMetadata(config: DocsConfig, page: {
33
- title: string;
34
- description?: string;
35
- }): Record<string, unknown>;
31
+ declare function createPageMetadata(config: DocsConfig, page: Pick<PageFrontmatter, "title" | "description" | "ogImage" | "openGraph" | "twitter">, baseUrl?: string): Record<string, unknown>;
36
32
  declare function createDocsLayout(config: DocsConfig): ({
37
33
  children
38
34
  }: {
@@ -8,6 +8,7 @@ import fs from "node:fs";
8
8
  import path from "node:path";
9
9
  import matter from "gray-matter";
10
10
  import { DocsLayout } from "fumadocs-ui/layouts/docs";
11
+ import { buildPageOpenGraph, buildPageTwitter } from "@farming-labs/docs";
11
12
 
12
13
  //#region src/docs-layout.tsx
13
14
  /** Resolve a frontmatter `icon` string to a ReactNode via the icon registry. */
@@ -231,42 +232,28 @@ function createDocsMetadata(config) {
231
232
  return result;
232
233
  }
233
234
  /**
234
- * Generate page-level metadata with dynamic OG images.
235
+ * Generate page-level metadata with dynamic or static OG/twitter.
236
+ * When the page has `openGraph` or `twitter` in frontmatter, those are used (static OG).
237
+ * Otherwise uses `ogImage` or the config dynamic endpoint.
235
238
  *
236
239
  * Usage in a docs page or [[...slug]] route:
237
240
  * ```ts
238
241
  * export function generateMetadata({ params }) {
239
242
  * const page = getPage(params.slug);
240
- * return createPageMetadata(docsConfig, {
241
- * title: page.data.title,
242
- * description: page.data.description,
243
- * });
243
+ * return createPageMetadata(docsConfig, page.data);
244
244
  * }
245
245
  * ```
246
246
  */
247
- function createPageMetadata(config, page) {
248
- const og = config.og;
247
+ function createPageMetadata(config, page, baseUrl) {
249
248
  const result = {
250
249
  title: page.title,
251
250
  ...page.description ? { description: page.description } : {}
252
251
  };
253
- if (og?.enabled !== false && og?.endpoint) {
254
- const ogUrl = `${og.endpoint}?title=${encodeURIComponent(page.title)}${page.description ? `&description=${encodeURIComponent(page.description)}` : ""}`;
255
- result.openGraph = {
256
- title: page.title,
257
- description: page.description,
258
- images: [{
259
- url: ogUrl,
260
- width: 1200,
261
- height: 630
262
- }]
263
- };
264
- result.twitter = {
265
- card: "summary_large_image",
266
- title: page.title,
267
- description: page.description,
268
- images: [ogUrl]
269
- };
252
+ if (config.og?.enabled !== false) {
253
+ const openGraph = buildPageOpenGraph(page, config.og, baseUrl);
254
+ if (openGraph) result.openGraph = openGraph;
255
+ const twitter = buildPageTwitter(page, config.og, baseUrl);
256
+ if (twitter) result.twitter = twitter;
270
257
  }
271
258
  return result;
272
259
  }
package/dist/index.d.mts CHANGED
@@ -5,8 +5,8 @@ import { DocsPageClient } from "./docs-page-client.mjs";
5
5
  import { RootProvider } from "./provider.mjs";
6
6
  import { PageActions } from "./page-actions.mjs";
7
7
  import { DocsLayout } from "fumadocs-ui/layouts/docs";
8
- import { DocsBody, DocsPage } from "fumadocs-ui/layouts/docs/page";
9
8
  import { AIConfig, BreadcrumbConfig, CopyMarkdownConfig, DocsConfig, DocsMetadata, DocsNav, DocsTheme, FontStyle, OGConfig, OpenDocsConfig, OpenDocsProvider, PageActionsConfig, PageFrontmatter, SidebarConfig, ThemeToggleConfig, TypographyConfig, UIConfig, createTheme, deepMerge, defineDocs, extendTheme } from "@farming-labs/docs";
9
+ import { DocsBody, DocsPage } from "fumadocs-ui/layouts/docs/page";
10
10
  import { Tab, Tabs } from "fumadocs-ui/components/tabs";
11
11
  import { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre } from "fumadocs-ui/components/codeblock";
12
12
  export { type AIConfig, type BreadcrumbConfig, CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, type CopyMarkdownConfig, DocsBody, DocsCommandSearch, type DocsConfig, DocsLayout, type DocsMetadata, type DocsNav, DocsPage, DocsPageClient, type DocsTheme, type FontStyle, DefaultUIDefaults as FumadocsUIDefaults, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, PageActions, type PageActionsConfig, type PageFrontmatter, Pre, RootProvider, type SidebarConfig, Tab, Tabs, type ThemeToggleConfig, type TypographyConfig, type UIConfig, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs };
package/dist/index.mjs CHANGED
@@ -5,8 +5,8 @@ import { createDocsLayout, createDocsMetadata, createPageMetadata } from "./docs
5
5
  import { RootProvider } from "./provider.mjs";
6
6
  import { DefaultUIDefaults, fumadocs } from "./default/index.mjs";
7
7
  import { DocsLayout } from "fumadocs-ui/layouts/docs";
8
- import { DocsBody, DocsPage } from "fumadocs-ui/layouts/docs/page";
9
8
  import { createTheme, deepMerge, defineDocs, extendTheme } from "@farming-labs/docs";
9
+ import { DocsBody, DocsPage } from "fumadocs-ui/layouts/docs/page";
10
10
  import { Tab, Tabs } from "fumadocs-ui/components/tabs";
11
11
  import { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre } from "fumadocs-ui/components/codeblock";
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farming-labs/theme",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
5
5
  "keywords": [
6
6
  "docs",
@@ -103,7 +103,7 @@
103
103
  "next": ">=14.0.0",
104
104
  "tsdown": "^0.20.3",
105
105
  "typescript": "^5.9.3",
106
- "@farming-labs/docs": "0.0.10"
106
+ "@farming-labs/docs": "0.0.12"
107
107
  },
108
108
  "peerDependencies": {
109
109
  "@farming-labs/docs": ">=0.0.1",
@@ -259,6 +259,8 @@ aside button.text-fd-muted-foreground:hover {
259
259
  aside a[data-active="true"]::before {
260
260
  background-color: var(--color-fd-primary) !important;
261
261
  width: 2px !important;
262
+ height: 40% !important;
263
+ margin-top: -1.5px !important;
262
264
  margin-left: 0.6rem !important;
263
265
  inset-inline-start: 0.5rem !important;
264
266
  }