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(composable): add useMedia composable #1370

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions .changeset/stale-cameras-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-pwa/composables-next": minor
---

Add `useMedia` composable for working with media
4 changes: 4 additions & 0 deletions apps/docs/.vitepress/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export const sidebar = [
text: "Multiple CMS",
link: "/getting-started/cms/multiple-cms.html",
},
{
text: "Fetching Media",
link: "/getting-started/cms/fetching-media.html",
},
],
},
{
Expand Down
26 changes: 26 additions & 0 deletions apps/docs/src/getting-started/cms/fetching-media.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
head:
- - meta
- name: og:title
content: Fetching Media - Shopware Frontends
- - meta
- name: og:description
content: "Fetching Media (CMS)"
- - meta
- name: og:image
content: "https://frontends-og-image.vercel.app/Fetching%20Media?fontSize=150px"
---

# Fetching Media (CMS)

To fetch Media objects you can use `readMedia post /media` endpoint.

## Example

```ts
const { data } = await apiClient.invoke("readMedia post /media", {
body: {
ids: ["a69d392ee875484095bf0b20b20c842b"],
},
});
```
6 changes: 5 additions & 1 deletion examples/api-client-tutorial/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"recommendations": ["astro-build.astro-vscode", "StackBlitz.tutorialkit", "unifiedjs.vscode-mdx"],
"recommendations": [
"astro-build.astro-vscode",
"StackBlitz.tutorialkit",
"unifiedjs.vscode-mdx"
],
"unwantedRecommendations": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<body>
<div class="center">
<h1 class="center">Live example</h1>
<pre id="result"><button id="loadContext">Load context via API Client</button></pre>
<pre
id="result"
><button id="loadContext">Load context via API Client</button></pre>
</div>
<script type="module" src="/main.ts"></script>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<body>
<div class="center">
<h1 class="center">Live example</h1>
<pre id="result"><button id="loadContext">Click to load context via API Client</button></pre>
<pre
id="result"
><button id="loadContext">Click to load context via API Client</button></pre>
</div>
<script type="module" src="/main.ts"></script>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<body>
<div class="center">
<h1 class="center">Live example</h1>
<pre id="result"><button id="loadContext">Load context via API Client</button></pre>
<pre
id="result"
><button id="loadContext">Load context via API Client</button></pre>
</div>
<script type="module" src="/main.ts"></script>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21009,4 +21009,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21009,4 +21009,4 @@
}
}
]
}
}
12 changes: 4 additions & 8 deletions examples/api-client-tutorial/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
"baseUrl": "./",
"jsxImportSource": "solid-js",
"paths": {
"@*": [
"src/*"
]
},
"@*": ["src/*"]
}
},
"exclude": [
"dist"
]
}
"exclude": ["dist"]
}
Loading
Loading