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

docs: support detecting broken link cross-projects #10483

Merged
merged 2 commits into from
Dec 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
2 changes: 1 addition & 1 deletion www/apps/api-reference/markdown/admin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ If you click on the workflow, you'll view a reference of that workflow, includin

This is useful if you want to extend an API route and pass additional data or perform custom actions.

Refer to [this guide](https://docs.medusajs.com/learn/customization/extend-features/extend-create-product) to find an example of extending an API route.
Refer to [this guide](!docs!/learn/customization/extend-features/extend-create-product) to find an example of extending an API route.

<Feedback
event="survey_api-ref"
Expand Down
4 changes: 2 additions & 2 deletions www/apps/api-reference/markdown/client-libraries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DownloadFull from "@/components/DownloadFull"

<H3 className="!mt-0">Just Getting Started?</H3>

Check out the [Medusa v2 Documentation](https://docs.medusajs.com).
Check out the [Medusa v2 Documentation](!docs!).

<Space bottom={8} />

Expand All @@ -16,7 +16,7 @@ To use Medusa's JS SDK library, install the following packages in your project (
npm install @medusajs/js-sdk@latest @medusajs/types@latest
```

Learn more about the JS SDK in [this documentation](https://docs.medusajs.com/resources/js-sdk).
Learn more about the JS SDK in [this documentation](!resources!/js-sdk).

### Download Full Reference

Expand Down
2 changes: 1 addition & 1 deletion www/apps/api-reference/markdown/store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ If you click on the workflow, you'll view a reference of that workflow, includin

This is useful if you want to extend an API route and pass additional data or perform custom actions.

Refer to [this guide](https://docs.medusajs.com/learn/customization/extend-features/extend-create-product) to find an example of extending an API route.
Refer to [this guide](!docs!/learn/customization/extend-features/extend-create-product) to find an example of extending an API route.

<Feedback
event="survey_api-ref"
Expand Down
47 changes: 47 additions & 0 deletions www/apps/api-reference/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import createMDX from "@next/mdx"
import bundleAnalyzer from "@next/bundle-analyzer"
import rehypeMdxCodeProps from "rehype-mdx-code-props"
import rehypeSlug from "rehype-slug"
import {
brokenLinkCheckerPlugin,
crossProjectLinksPlugin,
} from "remark-rehype-plugins"
import path from "path"

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand All @@ -28,6 +33,48 @@ const nextConfig = {
const withMDX = createMDX({
options: {
rehypePlugins: [
[
brokenLinkCheckerPlugin,
{
crossProjects: {
docs: {
projectPath: path.resolve("..", "book"),
},
resources: {
projectPath: path.resolve("..", "resources"),
hasGeneratedSlugs: true,
},
ui: {
projectPath: path.resolve("..", "ui"),
contentPath: "src/content/docs",
},
},
},
],
[
crossProjectLinksPlugin,
{
baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
projectUrls: {
docs: {
url: process.env.NEXT_PUBLIC_DOCS_URL,
path: "",
},
resources: {
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
},
"user-guide": {
url: process.env.NEXT_PUBLIC_USER_GUIDE_URL,
},
ui: {
url: process.env.NEXT_PUBLIC_UI_URL,
},
},
useBaseUrl:
process.env.NODE_ENV === "production" ||
process.env.VERCEL_ENV === "production",
},
],
[
rehypeMdxCodeProps,
{
Expand Down
1 change: 1 addition & 0 deletions www/apps/api-reference/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react-transition-group": "^4.4.5",
"rehype-mdx-code-props": "^3.0.1",
"rehype-slug": "^6.0.0",
"remark-rehype-plugins": "*",
"slugify": "^1.6.6",
"swr": "^2.2.0",
"tailwind": "*",
Expand Down
2 changes: 1 addition & 1 deletion www/apps/book/app/learn/basics/workflows/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,6 @@ You can now execute this workflow in a custom API route, scheduled job, or subsc

<Note title="Tip">

Find a full list of the registered resources in the Medusa container and their registration key in [this reference](!resources!/resources/medusa-container-resources). You can use these resources in your custom workflows.
Find a full list of the registered resources in the Medusa container and their registration key in [this reference](!resources!/medusa-container-resources). You can use these resources in your custom workflows.

</Note>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const metadata = {

# {metadata.title}

In the previous chapters, you [defined a link](../define-link/page.mdx) between the [custom Brand Module](../../custom-features/module/page.mdx) and Medusa's [Product Module](!resources!/comerce-modules/product), then [extended the create-product flow](../extend-create-product/page.mdx) to link a product to a brand.
In the previous chapters, you [defined a link](../define-link/page.mdx) between the [custom Brand Module](../../custom-features/module/page.mdx) and Medusa's [Product Module](!resources!/commerce-modules/product), then [extended the create-product flow](../extend-create-product/page.mdx) to link a product to a brand.

In this chapter, you'll learn how to retrieve a product's brand (and vice-versa) in two ways: Using Medusa's existing API route, or in customizations, such as a custom API route.

Expand Down
17 changes: 16 additions & 1 deletion www/apps/book/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,27 @@ import {
crossProjectLinksPlugin,
} from "remark-rehype-plugins"
import { sidebar } from "./sidebar.mjs"
import path from "path"

const withMDX = mdx({
extension: /\.mdx?$/,
options: {
rehypePlugins: [
[
brokenLinkCheckerPlugin,
{
crossProjects: {
resources: {
projectPath: path.resolve("..", "resources"),
hasGeneratedSlugs: true,
},
ui: {
projectPath: path.resolve("..", "ui"),
contentPath: "src/content/docs",
},
},
},
],
[
crossProjectLinksPlugin,
{
Expand All @@ -37,7 +53,6 @@ const withMDX = mdx({
process.env.VERCEL_ENV === "production",
},
],
[brokenLinkCheckerPlugin],
[localLinksRehypePlugin],
[
rehypeMdxCodeProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const metadata = {
The Medusa Admin has two types of forms:

1. Create forms, created using the [FocusModal UI component](!ui!/components/focus-modal).
2. Edit or update forms, created using the [Drawer UI component](!ui!/ui/components/drawer).
2. Edit or update forms, created using the [Drawer UI component](!ui!/components/drawer).

This guide explains how to create these two form types following the Medusa Admin's conventions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ remoteLink.create({

<Note title="Tip">

Learn more about the remote link in [this documentation](!docs!/advanced-development/module-links/remote-link).
Learn more about the remote link in [this documentation](!docs!/learn/advanced-development/module-links/remote-link).

</Note>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In this document, you'll learn how to calculate a product variant's price with t

You'll need the following resources for the taxes calculation:

1. [Query](!docs!/advanced-development/module-links/query) to retrieve the product's variants' prices for a context. Learn more about that in [this guide](../price/page.mdx).
1. [Query](!docs!/learn/advanced-development/module-links/query) to retrieve the product's variants' prices for a context. Learn more about that in [this guide](../price/page.mdx).
2. The Tax Module's main service to get the tax lines for each product.

```ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ To do that, you'll consume the [promotionsCreated](/references/medusa-workflows/

<Note title="Tip">

Learn more about workflow hooks in [this guide](!docs!/advanced-development/workflows/workflow-hooks).
Learn more about workflow hooks in [this guide](!docs!/learn/advanced-development/workflows/workflow-hooks).

</Note>

Expand Down Expand Up @@ -156,7 +156,7 @@ In the snippet above, you add a validation rule indicating that `custom_name` is

<Note title="Tip">

Learn more about additional data validation in [this guide](!docs!/advanced-development/api-routes/additional-data).
Learn more about additional data validation in [this guide](!docs!/learn/advanced-development/api-routes/additional-data).

</Note>

Expand Down Expand Up @@ -208,7 +208,7 @@ In the compensation function that undoes the step's actions in case of an error,

<Note title="Tip">

Learn more about compensation functions in [this guide](!docs!/advanced-development/workflows/compensation-function).
Learn more about compensation functions in [this guide](!docs!/learn/advanced-development/workflows/compensation-function).

</Note>

Expand Down Expand Up @@ -266,9 +266,9 @@ The workflow accepts as an input the created promotion and the `additional_data`

In the workflow, you:

1. Use the `transform` utility to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/advanced-development/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
1. Use the `transform` utility to get the value of `custom_name` based on whether it's set in `additional_data`. Learn more about why you can't use conditional operators in a workflow without using `transform` in [this guide](!docs!/learn/advanced-development/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
2. Create the `Custom` record using the `createCustomStep`.
3. Use the `when-then` utility to link the promotion to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/advanced-development/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).
3. Use the `when-then` utility to link the promotion to the `Custom` record if it was created. Learn more about why you can't use if-then conditions in a workflow without using `when-then` in [this guide](!docs!/learn/advanced-development/workflows/conditions#why-if-conditions-arent-allowed-in-workflows).

You'll next execute the workflow in the hook handler.

Expand Down Expand Up @@ -379,7 +379,7 @@ Among the returned `promotion` object, you'll find a `custom` property which hol

### Retrieve using Query

You can also retrieve the `Custom` record linked to a promotion in your code using [Query](!docs!/advanced-development/module-links/query).
You can also retrieve the `Custom` record linked to a promotion in your code using [Query](!docs!/learn/advanced-development/module-links/query).

For example:

Expand All @@ -393,7 +393,7 @@ const { data: [promotion] } = await query.graph({
})
```

Learn more about how to use Query in [this guide](!docs!/advanced-development/module-links/query).
Learn more about how to use Query in [this guide](!docs!/learn/advanced-development/module-links/query).

---

Expand Down
2 changes: 1 addition & 1 deletion www/apps/resources/app/recipes/b2b/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ The Medusa Admin plugin can be extended to add widgets, new pages, and setting p
icon: AcademicCapSolid,
},
{
href: "!docs!/learn/advanced-development/admin/setting-pages",
href: "!docs!/learn/advanced-development/admin/ui-routes#create-settings-page",
title: "Create Admin Setting Page",
text: "Learn how to add new page to the Medusa Admin settings.",
icon: AcademicCapSolid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ This loops over the returned subscriptions and executes the `createSubscriptionO

### Further Reads

- [How to Create a Scheduled Job](!docs!/learn/basics/scheeduled-jobs)
- [How to Create a Scheduled Job](!docs!/learn/basics/scheduled-jobs)

---

Expand Down
3 changes: 0 additions & 3 deletions www/apps/resources/generated/sidebar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9118,9 +9118,6 @@ export const generatedSidebar = [
}
]
},
{
"type": "separator"
},
{
"loaded": true,
"isPathHref": true,
Expand Down
16 changes: 15 additions & 1 deletion www/apps/resources/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ import {
workflowDiagramLinkFixerPlugin,
} from "remark-rehype-plugins"
import mdxPluginOptions from "./mdx-options.mjs"
import path from "node:path"

const withMDX = mdx({
extension: /\.mdx?$/,
options: {
rehypePlugins: [
[
brokenLinkCheckerPlugin,
{
crossProjects: {
docs: {
projectPath: path.resolve("..", "book"),
},
ui: {
projectPath: path.resolve("..", "ui"),
contentPath: "src/content/docs",
},
},
},
],
...mdxPluginOptions.options.rehypePlugins,
[brokenLinkCheckerPlugin],
[localLinksRehypePlugin],
[typeListLinkFixerPlugin],
[
Expand Down
3 changes: 0 additions & 3 deletions www/apps/resources/sidebar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2131,9 +2131,6 @@ export const sidebar = sidebarAttachHrefCommonOptions([
},
],
},
{
type: "separator",
},
{
type: "category",
title: "General",
Expand Down
4 changes: 2 additions & 2 deletions www/apps/resources/utils/get-slugs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ const monoRepoPath = path.resolve("..", "..", "..")
/**
*
* @param {string} dir - The directory to search in
* @returns {Promise<{ origSlug: string; newSlug: string }[]>}
* @returns {Promise<import("types").SlugChange[]>}
*/
export default async function getSlugs(options = {}) {
let { dir, basePath = path.resolve("app"), baseSlug = basePath } = options
if (!dir) {
dir = basePath
}
/**
* @type {{ origSlug: string; newSlug: string }[]}
* @type {import("types").SlugChange[]}
*/
const slugs = []

Expand Down
Loading
Loading