Thomas G. Lopes commited on
Commit
55b300a
·
1 Parent(s): 761e5b4

fix copy code

Browse files
src/lib/components/Avatar.svelte CHANGED
@@ -1,4 +1,6 @@
1
  <script lang="ts">
 
 
2
  export let orgName: string | undefined;
3
  export let size: "sm" | "md" = "md";
4
 
@@ -7,6 +9,7 @@
7
  async function getAvatarUrl(orgName?: string) {
8
  if (!orgName) return;
9
  const url = `https://huggingface.co/api/organizations/${orgName}/avatar`;
 
10
  const res = await fetch(url);
11
  if (!res.ok) {
12
  console.error(`Error getting avatar url for org: ${orgName}`, res.status, res.statusText);
 
1
  <script lang="ts">
2
+ import { browser } from "$app/environment";
3
+
4
  export let orgName: string | undefined;
5
  export let size: "sm" | "md" = "md";
6
 
 
9
  async function getAvatarUrl(orgName?: string) {
10
  if (!orgName) return;
11
  const url = `https://huggingface.co/api/organizations/${orgName}/avatar`;
12
+ if (!browser) return;
13
  const res = await fetch(url);
14
  if (!res.ok) {
15
  console.error(`Error getting avatar url for org: ${orgName}`, res.status, res.statusText);
src/lib/components/InferencePlayground/InferencePlaygroundCodeSnippets.svelte CHANGED
@@ -109,8 +109,13 @@
109
  return hljs.highlight(code, { language: language === "curl" ? "http" : language }).value;
110
  }
111
 
112
- function copy(el: HTMLElement, content: string) {
113
  let timeout: Timer;
 
 
 
 
 
114
 
115
  function onClick() {
116
  el.classList.add("text-green-500");
@@ -123,6 +128,7 @@
123
  el.addEventListener("click", onClick);
124
 
125
  return {
 
126
  destroy() {
127
  clearTimeout(timeout);
128
  el.removeEventListener("click", onClick);
@@ -191,7 +197,7 @@
191
  <div class="flex items-center gap-x-4">
192
  <button
193
  class="flex items-center gap-x-2 rounded-md border bg-white px-1.5 py-0.5 text-sm shadow-xs transition dark:border-gray-800 dark:bg-gray-800"
194
- use:copy={selectedSnippet.content}
195
  >
196
  <IconCopyCode classNames="text-xs" /> Copy code
197
  </button>
 
109
  return hljs.highlight(code, { language: language === "curl" ? "http" : language }).value;
110
  }
111
 
112
+ function copy(el: HTMLElement, _content: string) {
113
  let timeout: Timer;
114
+ let content = _content;
115
+
116
+ function update(_content: string) {
117
+ content = _content;
118
+ }
119
 
120
  function onClick() {
121
  el.classList.add("text-green-500");
 
128
  el.addEventListener("click", onClick);
129
 
130
  return {
131
+ update,
132
  destroy() {
133
  clearTimeout(timeout);
134
  el.removeEventListener("click", onClick);
 
197
  <div class="flex items-center gap-x-4">
198
  <button
199
  class="flex items-center gap-x-2 rounded-md border bg-white px-1.5 py-0.5 text-sm shadow-xs transition dark:border-gray-800 dark:bg-gray-800"
200
+ use:copy={installInstructions.content}
201
  >
202
  <IconCopyCode classNames="text-xs" /> Copy code
203
  </button>