Skip to content

Commit

Permalink
Correctly render changelog on website after new formatting (#5009)
Browse files Browse the repository at this point in the history
* fix changelog rendering

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <[email protected]>
  • Loading branch information
aliabd and gradio-pr-bot authored Jul 24, 2023
1 parent e549bf1 commit 3e70fc8
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/fruity-olives-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"website": patch
---

feat:Correctly render changelog on website after new formatting
10 changes: 3 additions & 7 deletions js/_website/generate_jsons/src/changelog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ def clean():

# remove empty/unused sections
content = re.sub(r"## [\w^:\n ]*No changes to highlight.", "", content)
content = content.replace("# gradio", "# Changelog")

# get versions and their correct href
versions = re.findall(r"# Version \d\.\d[^\n ]*", content)
versions = [("Upcoming Release", "upcoming-release")] + [("v" + v.strip("# Version "), "version-" + v.strip("# Version ").replace('.','')) for v in versions]

return content, versions
return content


def generate(json_path):
content, versions = clean()
content = clean()
with open(json_path, 'w+') as f:
json.dump({
"content": content,
"versions": versions
}, f)
11 changes: 5 additions & 6 deletions js/_website/src/routes/changelog/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { compile } from "mdsvex";
import anchor from "../../assets/img/anchor.svg";

let content = changelog_json.content;
let versions = changelog_json.versions;
import { make_slug_processor } from "../../utils";
import { toString as to_string } from "hast-util-to-string";

Expand Down Expand Up @@ -32,10 +31,10 @@ function highlight(code: string, lang: string | undefined) {

const highlighted = _lang
? `<pre class="language-${lang}"><code>${Prism.highlight(
code,
Prism.languages[_lang],
_lang
)}</code></pre>`
code,
Prism.languages[_lang],
_lang
)}</code></pre>`
: code;

return highlighted;
Expand All @@ -48,7 +47,7 @@ export async function load() {
function plugin() {
return function transform(tree: any) {
tree.children.forEach((n: any) => {
if (n.type === "element" && ["h1"].includes(n.tagName)) {
if (n.type === "element" && ["h2"].includes(n.tagName)) {
const str_of_heading = to_string(n);
const slug = get_slug(str_of_heading);

Expand Down
2 changes: 1 addition & 1 deletion js/_website/src/routes/changelog/changelog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/_website/src/routes/docs/docs.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/_website/src/routes/guides/json/Gradio-and-Comet.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/_website/src/routes/guides/json/guides_by_category.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/_website/src/routes/guides/json/sharing-your-app.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/_website/src/routes/guides/json/theming-guide.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// vite.config.ts
import { sveltekit } from "file:///Users/aliabdalla/Desktop/dev/gradio/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sveltejs/kit/src/exports/vite/index.js";
import { defineConfig } from "file:///Users/aliabdalla/Desktop/dev/gradio/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/vite/dist/node/index.js";
var vite_config_default = defineConfig({
plugins: [sveltekit()]
});
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvYWxpYWJkYWxsYS9EZXNrdG9wL2Rldi9ncmFkaW8vanMvX3dlYnNpdGVcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIi9Vc2Vycy9hbGlhYmRhbGxhL0Rlc2t0b3AvZGV2L2dyYWRpby9qcy9fd2Vic2l0ZS92aXRlLmNvbmZpZy50c1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vVXNlcnMvYWxpYWJkYWxsYS9EZXNrdG9wL2Rldi9ncmFkaW8vanMvX3dlYnNpdGUvdml0ZS5jb25maWcudHNcIjtpbXBvcnQgeyBzdmVsdGVraXQgfSBmcm9tIFwiQHN2ZWx0ZWpzL2tpdC92aXRlXCI7XG5pbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tIFwidml0ZVwiO1xuXG5leHBvcnQgZGVmYXVsdCBkZWZpbmVDb25maWcoe1xuXHRwbHVnaW5zOiBbc3ZlbHRla2l0KCldXG59KTtcbiJdLAogICJtYXBwaW5ncyI6ICI7QUFBa1UsU0FBUyxpQkFBaUI7QUFDNVYsU0FBUyxvQkFBb0I7QUFFN0IsSUFBTyxzQkFBUSxhQUFhO0FBQUEsRUFDM0IsU0FBUyxDQUFDLFVBQVUsQ0FBQztBQUN0QixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo=

1 comment on commit 3e70fc8

@vercel
Copy link

@vercel vercel bot commented on 3e70fc8 Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.