Skip to content

Commit bab4aef

Browse files
Fix script that updates the Algolia index on merge. (#1288)
* Fix search index script. Move lots of lib around. * Rename files to camelcase * Make diff readable * Use mjs * Force 20.19.3 * Update package-lock.json --------- Co-authored-by: Debbie Matthews <[email protected]>
1 parent 2dae576 commit bab4aef

25 files changed

+4092
-5875
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.8.1
1+
v20.19.3

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ If you know the answer to a Streamlit user's pain point and want to add it to th
263263
1. Decide which of the above sections your article belongs to
264264
2. Navigate to the relevant section's folder in `kb/` and
265265
3. Create a `.md` file in the above specified format containing your article
266-
267266
- Make sure the title in the front matter and the file header in Markdown are identical. E.g.
268267

269268
```markdown

components/blocks/autofunction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import getConfig from "next/config";
1717
const { publicRuntimeConfig } = getConfig();
1818

1919
import styles from "./autofunction.module.css";
20-
import { looksLikeVersionAndPlatformString } from "../../context/VersionContext";
20+
import { looksLikeVersionAndPlatformString } from "../../lib/next/utils";
2121

2222
const LATEST_VERSION = publicRuntimeConfig.LATEST_VERSION;
2323
const DEFAULT_VERSION = publicRuntimeConfig.DEFAULT_VERSION;

components/navigation/mobileNav.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect } from "react";
2-
import bus from "../../lib/bus";
2+
import bus from "../../lib/node/bus";
33
import router from "next/router";
44

55
import styles from "./mobileNav.module.css";

components/navigation/navChild.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Link from "next/link";
33
import classNames from "classnames";
44

55
import styles from "./navChild.module.css";
6-
import { looksLikeVersionAndPlatformString } from "../../context/VersionContext";
6+
import { looksLikeVersionAndPlatformString } from "../../lib/next/utils";
77

88
const NavChild = ({ slug, page, color, className }) => {
99
const [manualState, setManualState] = useState(null);

components/navigation/navItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react";
22
import Link from "next/link";
33
import classNames from "classnames";
44

5-
import { urlInChildren } from "../../lib/utils.js";
5+
import { urlInChildren } from "../../lib/purejs/breadcrumbHelpers";
66
import NavChild from "./navChild";
77

88
import styles from "./navItem.module.css";

components/navigation/sideBar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { debounce } from "lodash";
22
import React, { useState, useEffect } from "react";
33
import classNames from "classnames";
44

5-
import bus from "../../lib/bus";
5+
import bus from "../../lib/node/bus";
66
import NavItem from "../navigation/navItem";
77

88
import styles from "./sideBar.module.css";
@@ -94,7 +94,7 @@ const SideBar = ({ menu, slug }) => {
9494
styles.Container,
9595
isOpen ? styles.OpenNav : styles.ClosedNav,
9696
isOver ? styles.OverNav : styles.CollapsedNav,
97-
isSticky === "window" && styles.WindowStickyNav
97+
isSticky === "window" && styles.WindowStickyNav,
9898
)}
9999
onScroll={(e) => handleScroll(e)}
100100
>
@@ -104,8 +104,8 @@ const SideBar = ({ menu, slug }) => {
104104
isSticky === "window"
105105
? styles.WindowStickyGradient
106106
: isSticky === "scrollbar"
107-
? styles.ScrollBarStickyGradient
108-
: styles.StandardGradient
107+
? styles.ScrollBarStickyGradient
108+
: styles.StandardGradient,
109109
)}
110110
/>
111111
<nav onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>

components/utilities/breadCrumbs.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from "react";
2-
import { breadcrumbsForSlug } from "../../lib/utils.js";
32
import Link from "next/link";
43

4+
import { breadcrumbsForSlug } from "../../lib/purejs/breadcrumbHelpers";
5+
import { looksLikeVersionAndPlatformString } from "../../lib/next/utils";
6+
57
import styles from "./breadCrumbs.module.css";
6-
import { looksLikeVersionAndPlatformString } from "../../context/VersionContext.js";
78

89
const BreadCrumbs = ({ slug, menu }) => {
910
const formatedTitle = (title) => {

content/develop/tutorials/execution-flow/fragments/trigger-a-full-script-rerun-from-a-fragment.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ with monthly:
157157
```
158158

159159
You'll be using these libraries as follows:
160-
161160
- You'll work with sales data in a `pandas.DataFrame`.
162161
- You'll generate random sales numbers with `numpy`.
163162
- The data will have `datetime.date` index values.

context/VersionContext.js renamed to lib/next/VersionContext.jsx

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import {
66
useEffect,
77
} from "react";
88
import getConfig from "next/config";
9+
10+
import { looksLikeVersionAndPlatformString } from "./utils";
11+
912
const { publicRuntimeConfig } = getConfig();
1013

1114
const VersionContext = createContext();
@@ -54,30 +57,6 @@ export function useVersionContext() {
5457
return useContext(VersionContext);
5558
}
5659

57-
export function looksLikeVersionAndPlatformString(urlPart) {
58-
const platforms = [DEFAULT_PLATFORM].concat(Object.keys(PLATFORM_VERSIONS));
59-
60-
// docs.streamlit.io/1.23.0/path1/path2
61-
const isPureVersion = /^[\d\.]+$/.test(urlPart);
62-
if (isPureVersion) return true;
63-
64-
// docs.streamlit.io/latest/path1/path2
65-
const isLatestVersion = urlPart == "latest";
66-
if (isLatestVersion) return true;
67-
68-
// docs.streamlit.io/1.23.0-sis/path1/path2
69-
const versionPlatformRegex = RegExp(`^[\\d\\.]+-(${platforms.join("|")})$`);
70-
const isVersionWithPlatform = versionPlatformRegex.test(urlPart);
71-
if (isVersionWithPlatform) return true;
72-
73-
// docs.streamlit.io/latest-sis/path1/path2
74-
const latestPlatformRegex = RegExp(`^latest-(${platforms.join("|")})$`);
75-
const isLatestPlatform = latestPlatformRegex.test(urlPart);
76-
if (isLatestPlatform) return true;
77-
78-
return false;
79-
}
80-
8160
export function getVersionAndPlatformFromPathPart(pathPart) {
8261
if (!looksLikeVersionAndPlatformString(pathPart)) {
8362
return [null, null];

0 commit comments

Comments
 (0)