docs: add support for keywords in references (#12413)

This commit is contained in:
Shahed Nasser
2025-05-08 16:40:17 +03:00
committed by GitHub
parent 42bc2a1372
commit 0af6e1f212
18 changed files with 51 additions and 3 deletions
@@ -1,4 +1,5 @@
import { MDXRemote } from "next-mdx-remote/rsc" import { MDXRemote, MDXRemoteSerializeResult } from "next-mdx-remote/rsc"
import { serialize } from "next-mdx-remote/serialize"
import path from "path" import path from "path"
import { promises as fs } from "fs" import { promises as fs } from "fs"
import { notFound } from "next/navigation" import { notFound } from "next/navigation"
@@ -93,6 +94,7 @@ export async function generateMetadata({
} }
metadata.title = pageTitleMatch.groups.title metadata.title = pageTitleMatch.groups.title
metadata.keywords = (fileData.source.frontmatter?.keywords || []) as string[]
return metadata return metadata
} }
@@ -103,6 +105,7 @@ const loadFile = cache(
): Promise< ): Promise<
| { | {
content: string content: string
source: MDXRemoteSerializeResult
path: string path: string
} }
| undefined | undefined
@@ -120,8 +123,14 @@ const loadFile = cache(
return undefined return undefined
} }
const fullPath = path.join(monoRepoPath, fileDetails.filePath) const fullPath = path.join(monoRepoPath, fileDetails.filePath)
const fileContent = await fs.readFile(fullPath, "utf-8")
const serialized = await serialize(fileContent, {
parseFrontmatter: true,
})
return { return {
content: await fs.readFile(fullPath, "utf-8"), content: fileContent,
source: serialized,
path: fullPath, path: fullPath,
} }
} }
@@ -5,6 +5,10 @@ tags:
- server - server
- how to - how to
sidebar_label: Create Auth Provider sidebar_label: Create Auth Provider
keywords:
- auth
- provider
- integration
--- ---
import { TypeList } from "docs-ui" import { TypeList } from "docs-ui"
@@ -521,7 +525,7 @@ module.exports = defineConfig({
## 5. Test it Out ## 5. Test it Out
To test out your Authentication Module Provider, use any of the [Authentication Routes](https://docs.medusajs.com/v2/resources/commerce-modules/auth/authentication-route), using your provider's ID as a path parameter. To test out your Authentication Module Provider, use any of the [Authentication Routes](https://docs.medusajs.com/resources/commerce-modules/auth/authentication-route), using your provider's ID as a path parameter.
For example, to get a registration token for an admin user, send a `POST` request to `/auth/user/my-auth/register` replacing `my-auth` with your Authentication Module Provider's ID: For example, to get a registration token for an admin user, send a `POST` request to `/auth/user/my-auth/register` replacing `my-auth` with your Authentication Module Provider's ID:
@@ -5,6 +5,10 @@ tags:
- server - server
- how to - how to
sidebar_label: Use Cache Module sidebar_label: Use Cache Module
keywords:
- cache
- provider
- integration
--- ---
import { TypeList } from "docs-ui" import { TypeList } from "docs-ui"
@@ -5,6 +5,10 @@ tags:
- server - server
- how to - how to
sidebar_label: Use Event Module sidebar_label: Use Event Module
keywords:
- event
- provider
- integration
--- ---
import { TypeList } from "docs-ui" import { TypeList } from "docs-ui"
@@ -1,5 +1,10 @@
--- ---
slug: /references/file-provider-module slug: /references/file-provider-module
keywords:
- file
- storage
- provider
- integration
--- ---
import { TypeList } from "docs-ui" import { TypeList } from "docs-ui"
@@ -5,6 +5,10 @@ tags:
- server - server
- how to - how to
sidebar_label: Create Locking Provider sidebar_label: Create Locking Provider
keywords:
- locking
- provider
- integration
--- ---
import { TypeList } from "docs-ui" import { TypeList } from "docs-ui"
@@ -5,6 +5,10 @@ tags:
- server - server
- how to - how to
sidebar_label: Use Notification Module sidebar_label: Use Notification Module
keywords:
- notification
- provider
- integration
--- ---
import { TypeList } from "docs-ui" import { TypeList } from "docs-ui"
@@ -5,6 +5,10 @@ tags:
- server - server
- how to - how to
sidebar_label: Create Tax Provider sidebar_label: Create Tax Provider
keywords:
- tax
- provider
- integration
--- ---
import { TypeList } from "docs-ui" import { TypeList } from "docs-ui"
@@ -11,6 +11,7 @@ const authProviderOptions: FormattingOptionsType = {
slug: "/references/auth/provider", slug: "/references/auth/provider",
tags: ["auth", "server", "how to"], tags: ["auth", "server", "how to"],
sidebar_label: "Create Auth Provider", sidebar_label: "Create Auth Provider",
keywords: ["auth", "provider", "integration"],
}, },
reflectionTitle: { reflectionTitle: {
fullReplacement: "How to Create an Auth Module Provider", fullReplacement: "How to Create an Auth Module Provider",
@@ -10,6 +10,7 @@ const cacheOptions: FormattingOptionsType = {
slug: "/references/cache-service", slug: "/references/cache-service",
tags: ["cache", "server", "how to"], tags: ["cache", "server", "how to"],
sidebar_label: "Use Cache Module", sidebar_label: "Use Cache Module",
keywords: ["cache", "provider", "integration"],
}, },
reflectionTitle: { reflectionTitle: {
fullReplacement: "How to Use Cache Module", fullReplacement: "How to Use Cache Module",
@@ -10,6 +10,7 @@ const eventOptions: FormattingOptionsType = {
slug: "/references/event-service", slug: "/references/event-service",
tags: ["event", "server", "how to"], tags: ["event", "server", "how to"],
sidebar_label: "Use Event Module", sidebar_label: "Use Event Module",
keywords: ["event", "provider", "integration"],
}, },
reflectionTitle: { reflectionTitle: {
fullReplacement: "How to Use Event Module", fullReplacement: "How to Use Event Module",
@@ -9,6 +9,7 @@ const fileOptions: FormattingOptionsType = {
reflectionDescription: `In this document, youll learn how to create a File Module Provider and the methods you must implement in its main service.`, reflectionDescription: `In this document, youll learn how to create a File Module Provider and the methods you must implement in its main service.`,
frontmatterData: { frontmatterData: {
slug: "/references/file-provider-module", slug: "/references/file-provider-module",
keywords: ["file", "storage", "provider", "integration"],
}, },
reflectionTitle: { reflectionTitle: {
fullReplacement: "How to Create a File Module Provider", fullReplacement: "How to Create a File Module Provider",
@@ -11,6 +11,7 @@ const fulfillmentProviderOptions: FormattingOptionsType = {
slug: "/references/fulfillment/provider", slug: "/references/fulfillment/provider",
tags: ["fulfillment", "server", "how to"], tags: ["fulfillment", "server", "how to"],
sidebar_label: "Create Fulfillment Provider", sidebar_label: "Create Fulfillment Provider",
keywords: ["fulfillment", "shipping", "provider", "integration"],
}, },
reflectionTitle: { reflectionTitle: {
fullReplacement: "How to Create a Fulfillment Module Provider", fullReplacement: "How to Create a Fulfillment Module Provider",
@@ -11,6 +11,7 @@ const lockingOptions: FormattingOptionsType = {
slug: "/references/locking-module-provider", slug: "/references/locking-module-provider",
tags: ["locking", "server", "how to"], tags: ["locking", "server", "how to"],
sidebar_label: "Create Locking Provider", sidebar_label: "Create Locking Provider",
keywords: ["locking", "provider", "integration"],
}, },
reflectionTitle: { reflectionTitle: {
fullReplacement: "How to Create a Locking Module Provider", fullReplacement: "How to Create a Locking Module Provider",
@@ -10,6 +10,7 @@ const notificationServiceOptions: FormattingOptionsType = {
slug: "/references/notification-service", slug: "/references/notification-service",
tags: ["notification", "server", "how to"], tags: ["notification", "server", "how to"],
sidebar_label: "Use Notification Module", sidebar_label: "Use Notification Module",
keywords: ["notification", "provider", "integration"],
}, },
reflectionTitle: { reflectionTitle: {
fullReplacement: "How to Use Notification Module", fullReplacement: "How to Use Notification Module",
@@ -11,6 +11,7 @@ const paymentProviderOptions: FormattingOptionsType = {
slug: "/references/payment/provider", slug: "/references/payment/provider",
tags: ["payment", "server", "how to"], tags: ["payment", "server", "how to"],
sidebar_label: "Create Payment Provider", sidebar_label: "Create Payment Provider",
keywords: ["payment", "provider", "integration"],
}, },
reflectionTitle: { reflectionTitle: {
fullReplacement: "How to Create a Payment Module Provider", fullReplacement: "How to Create a Payment Module Provider",
@@ -10,6 +10,7 @@ const taxProviderOptions: FormattingOptionsType = {
slug: "/references/tax/provider", slug: "/references/tax/provider",
tags: ["tax", "server", "how to"], tags: ["tax", "server", "how to"],
sidebar_label: "Create Tax Provider", sidebar_label: "Create Tax Provider",
keywords: ["tax", "provider", "integration"],
}, },
reflectionTitle: { reflectionTitle: {
fullReplacement: "How to Create a Tax Module Provider", fullReplacement: "How to Create a Tax Module Provider",
+1
View File
@@ -62,6 +62,7 @@ export type FrontmatterData = {
sidebar_label?: string sidebar_label?: string
displayed_sidebar?: string displayed_sidebar?: string
tags?: Tag[] tags?: Tag[]
keywords?: string[]
[k: string]: unknown [k: string]: unknown
} }