docs: fix code block titles (#5733)
* docs: fix code block titles * remove console * fix build error
This commit is contained in:
@@ -54,7 +54,7 @@ The `MedusaProvider` requires two props:
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/App.ts
|
||||
```tsx title="src/App.ts"
|
||||
import { MedusaProvider } from "medusa-react"
|
||||
import Storefront from "./Storefront"
|
||||
import { QueryClient } from "@tanstack/react-query"
|
||||
@@ -90,7 +90,7 @@ Could not find a declaration file for module 'medusa-react'
|
||||
|
||||
Make sure to set `moduleResolution` in your `tsconfig.json` to `nodenext` or `node`:
|
||||
|
||||
```json title=tsconfig.json
|
||||
```json title="tsconfig.json"
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "nodenext",
|
||||
@@ -115,7 +115,7 @@ To fetch data from the Medusa backend (in other words, perform `GET` requests),
|
||||
|
||||
For example, to fetch products from your Medusa backend:
|
||||
|
||||
```tsx title=src/Products.ts
|
||||
```tsx title="src/Products.ts"
|
||||
import { Product } from "@medusajs/medusa"
|
||||
import { useProducts } from "medusa-react"
|
||||
|
||||
@@ -146,7 +146,7 @@ Instead of the `data` field, the response data is flattened and is part of the h
|
||||
|
||||
If the request accepts any parameters, they can be passed as parameters to the `mutate` request. For example:
|
||||
|
||||
```tsx title=src/Products.ts
|
||||
```tsx title="src/Products.ts"
|
||||
const { products } = useProducts({
|
||||
expand: "variants",
|
||||
})
|
||||
@@ -160,7 +160,7 @@ To create, update, or delete data on the Medusa backend (in other words, perform
|
||||
|
||||
For example, to create a cart:
|
||||
|
||||
```tsx title=src/Cart.ts
|
||||
```tsx title="src/Cart.ts"
|
||||
import { useCreateCart } from "medusa-react"
|
||||
|
||||
const Cart = () => {
|
||||
@@ -360,7 +360,7 @@ The request returns an object containing keys like `mutation` which is a functio
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/admin/routes/blog/posts/page.tsx
|
||||
```tsx title="src/admin/routes/blog/posts/page.tsx"
|
||||
import { useAdminCustomPost } from "medusa-react"
|
||||
import { useNavigate } from "react-router-dom"
|
||||
|
||||
@@ -438,7 +438,7 @@ The request returns an object containing keys like `mutation` which is a functio
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/admin/routes/blog/posts/[id]/page.tsx
|
||||
```tsx title="src/admin/routes/blog/posts/[id]/page.tsx"
|
||||
import { useAdminCustomDelete } from "medusa-react"
|
||||
import { useNavigate, useParams } from "react-router-dom"
|
||||
|
||||
@@ -502,7 +502,7 @@ It accepts an object with the following properties:
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/Products.ts
|
||||
```tsx title="src/Products.ts"
|
||||
import { formatVariantPrice } from "medusa-react"
|
||||
import { Product, ProductVariant } from "@medusajs/medusa"
|
||||
|
||||
@@ -542,7 +542,7 @@ It accepts an object with the following properties:
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/Products.ts
|
||||
```tsx title="src/Products.ts"
|
||||
import { computeVariantPrice } from "medusa-react"
|
||||
import { Product, ProductVariant } from "@medusajs/medusa"
|
||||
|
||||
@@ -587,7 +587,7 @@ It accepts an object with the following properties:
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/MyComponent.ts
|
||||
```tsx title="src/MyComponent.ts"
|
||||
import { formatAmount } from "medusa-react"
|
||||
|
||||
const MyComponent = () => {
|
||||
@@ -617,7 +617,7 @@ It accepts an object with the following properties:
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/MyComponent.ts
|
||||
```tsx title="src/MyComponent.ts"
|
||||
import { computeAmount } from "medusa-react"
|
||||
|
||||
const MyComponent = () => {
|
||||
@@ -655,7 +655,7 @@ To use `CartProvider`, you first have to insert it somewhere in your component t
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/App.ts
|
||||
```tsx title="src/App.ts"
|
||||
import { CartProvider, MedusaProvider } from "medusa-react"
|
||||
import Storefront from "./Storefront"
|
||||
import { QueryClient } from "@tanstack/react-query"
|
||||
@@ -695,7 +695,7 @@ The `useCart` hook returns an object with the following properties:
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/Cart.ts
|
||||
```tsx title="src/Cart.ts"
|
||||
import * as React from "react"
|
||||
|
||||
import { useCart } from "medusa-react"
|
||||
@@ -745,7 +745,7 @@ To use `SessionProvider`, you first have to insert it somewhere in your componen
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/App.ts
|
||||
```tsx title="src/App.ts"
|
||||
import { SessionProvider, MedusaProvider } from "medusa-react"
|
||||
import Storefront from "./Storefront"
|
||||
import { QueryClient } from "@tanstack/react-query"
|
||||
@@ -773,7 +773,7 @@ Then, in any of the child components, you can use the `useSessionHook` hook expo
|
||||
|
||||
For example:
|
||||
|
||||
```tsx title=src/Products.ts
|
||||
```tsx title="src/Products.ts"
|
||||
const Products = () => {
|
||||
const { addItem } = useSessionCart()
|
||||
// ...
|
||||
|
||||
Reference in New Issue
Block a user