diff --git a/website/homepage/render_html.py b/website/homepage/render_html.py index 038df03108..f33511d62a 100644 --- a/website/homepage/render_html.py +++ b/website/homepage/render_html.py @@ -44,7 +44,7 @@ def render_index(): guides = [] for guide in sorted(os.listdir(GRADIO_GUIDES_DIR)): - if guide.lower() in ["getting_started.md", "readme.md"]: + if guide.lower() == "readme.md": continue guide_name = guide[:-3] pretty_guide_name = " ".join( @@ -108,6 +108,7 @@ def render_guides(): code_tags = re.findall(r'\{\{ code\["([^\s]*)"\] \}\}', guide["content"]) demo_names = re.findall(r'\{\{ demos\["([^\s]*)"\] \}\}', guide["content"]) code, demos = {}, {} + guide["content"] = ( guide["content"] .replace("website/src/assets", "/assets") @@ -144,6 +145,12 @@ def render_guides(): guide_output, ) + copy_button = "" + guide_output = guide_output.replace("
", "
")
+        guide_output = guide_output.replace("
", f"
{copy_button}") + output_html = markdown2.markdown(guide_output, extras=["target-blank-links"]) for match in re.findall(r"

([A-Za-z0-9 ]*)<\/h3>", output_html): diff --git a/website/homepage/src/assets/img/copy-grey.svg b/website/homepage/src/assets/img/copy-grey.svg new file mode 100644 index 0000000000..a7c228aee6 --- /dev/null +++ b/website/homepage/src/assets/img/copy-grey.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/website/homepage/src/assets/img/copy-orange.svg b/website/homepage/src/assets/img/copy-orange.svg new file mode 100644 index 0000000000..1ded267297 --- /dev/null +++ b/website/homepage/src/assets/img/copy-orange.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/website/homepage/src/guides_template.html b/website/homepage/src/guides_template.html index 282c87677d..1871d51f66 100644 --- a/website/homepage/src/guides_template.html +++ b/website/homepage/src/guides_template.html @@ -42,6 +42,8 @@ .prose .code, .prose pre { + width: 95%; + border-radius: 4px 0 0 4px; color: black; background: rgb(249, 250, 251); } @@ -53,6 +55,22 @@ .prose h1 { font-weight: 600; } + + .copy { + padding-right: 1em; + background: #f9fafb; + } + + .copy-svg { + visibility: hidden; + margin: 1em 0 0 0 !important; + width: 20px; + } + + .code-block:hover .copy-svg { + visibility: visible; + } +