diff --git a/.github/workflows/algolia-crawler-hs-docs.yml b/.github/workflows/algolia-crawler-hs-docs.yml new file mode 100644 index 000000000000..944fadd5149d --- /dev/null +++ b/.github/workflows/algolia-crawler-hs-docs.yml @@ -0,0 +1,41 @@ +name: Algolia Indexer for HumanSignal Docs + +on: + push: + branches: ["develop"] + paths: + - "docs/**" + - ".github/workflows/algolia-crawler-hs-docs.yml" + pull_request: + branches: + - develop + +jobs: + algolia_indexer: + runs-on: ubuntu-latest + env: + APPLICATION_ID: "M7RXTHKYPM" + API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }} + INDEX_NAME: "ghaction" + CONFIG: > + {"index_name": "ghaction", + "stop_urls": ["https://docs.humansignal.com/guide/index.html", "https://docs.humansignal.com/guide/notion-faq.html", "https://labelstud.io/sdk/index.html"], + "selectors_exclude": [".home-page-index"], + "sitemap_urls": ["https://docs.humansignal.com/guide/sitemap-docs.xml", "https://labelstud.io/sitemap-blog.xml"], + "selectors": { + "default": { + "lvl0": ".content h1, .ResourcesBannerHeading, .BlogTitle", + "lvl1": ".content h2, .ResourcesContent h1, .ResourcesContent h2", + "lvl2": ".content h3, .ResourcesContent h3", + "lvl3": ".content h4, .ResourcesContent h4", + "lvl4": ".content h5, .ResourcesContent h5", + "lvl5": ".content h6, .ResourcesContent h6", + "content": ".content-markdown > *, .ResourcesContent > .Text" + } + } + } + name: Index Algolia + steps: + - name: Algolia Docsearch Action + id: algolia + uses: adapttive/algolia-docsearch-action@1.1.1 diff --git a/.github/workflows/algolia-crawler-ls-docs.yml b/.github/workflows/algolia-crawler-ls-docs.yml new file mode 100644 index 000000000000..88a0c1ced366 --- /dev/null +++ b/.github/workflows/algolia-crawler-ls-docs.yml @@ -0,0 +1,42 @@ +name: Algolia Indexer for Label Studio Docs + +on: + push: + branches: ["develop"] + paths: + - "docs/**" + - ".github/workflows/algolia-crawler-ls-docs.yml" + pull_request: + branches: + - develop + +jobs: + algolia_indexer: + runs-on: ubuntu-latest + env: + APPLICATION_ID: "M7RXTHKYPM" + API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }} + INDEX_NAME: "labelstudiodocs" + CONFIG: > + { + "index_name": "labelstudiodocs", + "stop_urls": ["https://labelstud.io/guide/index.html", "https://labelstud.io/sdk/index.html"], + "selectors_exclude": [".home-page-index"], + "sitemap_urls": ["https://labelstud.io/sitemap-blog.xml", "https://labelstud.io/guide/sitemap-docs.xml"], + "selectors": { + "default": { + "lvl0": ".content h1, .ResourcesBannerHeading, .BlogTitle", + "lvl1": ".content h2, .ResourcesContent h1, .ResourcesContent h2", + "lvl2": ".content h3, .ResourcesContent h3", + "lvl3": ".content h4, .ResourcesContent h4", + "lvl4": ".content h5, .ResourcesContent h5", + "lvl5": ".content h6, .ResourcesContent h6", + "content": ".content-markdown > *, .ResourcesContent > .Text" + } + } + } + name: Index Algolia + steps: + - name: Algolia Docsearch Action + id: algolia + uses: adapttive/algolia-docsearch-action@1.1.1 diff --git a/.github/workflows/algolia-crawler.yml b/.github/workflows/algolia-crawler.yml deleted file mode 100644 index 6431906b7716..000000000000 --- a/.github/workflows/algolia-crawler.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Algolia Indexer - -on: - push: - branches: [ 'develop' ] - paths: - - 'docs/**' - - '.github/workflows/algolia-crawler.yml' - -jobs: - algolia_indexer: - runs-on: ubuntu-latest - env: - APPLICATION_ID: "M7RXTHKYPM" - API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }} - INDEX_NAME: "ghaction" - CONFIG: > - {"index_name": "ghaction", - "stop_urls": ["https://docs.humansignal.com/guide/index.html", "https://docs.humansignal.com/guide/notion-faq.html", "https://labelstud.io/sdk/index.html"], - "selectors_exclude": [".home-page-index"], - "start_urls": ["https://docs.humansignal.com/guide", "https://docs.humansignal.com/templates", "https://docs.humansignal.com/tags", "https://labelstud.io/sdk/"], - "selectors": { - "lvl0": ".content h1, .ResourcesBannerHeading", - "lvl1": ".content h2, .ResourcesContent h2", - "lvl2": ".content h3, .ResourcesContent h3", - "lvl3": ".content h4, .ResourcesContent h4", - "lvl4": ".content h5, .ResourcesContent h5", - "lvl5": ".content h6, .ResourcesContent h6", - "content": ".content-markdown > *" - }} - name: Index Algolia - steps: - - name: Algolia Docsearch Action - id: algolia - uses: adapttive/algolia-docsearch-action@1.1.1 diff --git a/docs/themes/v2/source/js/header.js b/docs/themes/v2/source/js/header.js index 1aaef18820dd..eb658d837e13 100644 --- a/docs/themes/v2/source/js/header.js +++ b/docs/themes/v2/source/js/header.js @@ -1,8 +1,9 @@ -(function() { +(function () { const pageHeader = document.querySelector(".page-header"); const pageSidebar = document.querySelector(".page-sidebar"); const navToggleButtons = pageHeader.querySelectorAll("button"); - const sideBarToggleButtons = pageSidebar && pageSidebar.querySelectorAll("button"); + const sideBarToggleButtons = + pageSidebar && pageSidebar.querySelectorAll("button"); const hamburgerButton = pageHeader.querySelector(".hamburger-button"); const toggleMenu = (e) => { @@ -12,58 +13,84 @@ const arrow = button.querySelector("svg"); const arrowStyles = getComputedStyle(arrow); - arrow.style.setProperty('transform', arrowStyles.transform === "none" ? "matrix(-1, 0, 0, -1, 0, 0)" : "none"); - menu.style.setProperty('display', menuStyles.display === "flex" ? "none" : "flex"); - } - - navToggleButtons && navToggleButtons.forEach(button => button.addEventListener("click", toggleMenu)); - sideBarToggleButtons && sideBarToggleButtons.forEach(button => button.addEventListener("click", toggleMenu)); - - const githubstarsContainer = document.querySelector(".github-stars-count"); - - if(githubstarsContainer) { + arrow.style.setProperty( + "transform", + arrowStyles.transform === "none" ? "matrix(-1, 0, 0, -1, 0, 0)" : "none" + ); + menu.style.setProperty( + "display", + menuStyles.display === "flex" ? "none" : "flex" + ); + }; + + navToggleButtons && + navToggleButtons.forEach((button) => + button.addEventListener("click", toggleMenu) + ); + sideBarToggleButtons && + sideBarToggleButtons.forEach((button) => + button.addEventListener("click", toggleMenu) + ); + + const githubstarsContainer = document.querySelector(".github-stars-count"); + + if (githubstarsContainer) { fetch("https://api.github.com/repos/heartexlabs/label-studio") - .then((response) => response.json() - .then((data) => { - let stars = ""; - if(data.stargazers_count) stars = data.stargazers_count.toLocaleString('en-US') - if(stars) githubstarsContainer.textContent = stars; - })) - .catch((err) => { - console.log(err) - }); + .then((response) => + response.json().then((data) => { + let stars = ""; + if (data.stargazers_count) + stars = data.stargazers_count.toLocaleString("en-US"); + if (stars) githubstarsContainer.textContent = stars; + }) + ) + .catch((err) => { + console.log(err); + }); } - window.addEventListener('load', (event) => { + window.addEventListener("load", (event) => { const searchInput = document.querySelector("#docsearch-input"); const siteVersion = searchInput.dataset.siteVersion; - const appId = siteVersion == "enterprise" ? 'M7RXTHKYPM' : "HELLEDAKPT"; - const apiKey = siteVersion == "enterprise" ? '8ed23cbc92e0806140603fb62236efee' : '1d0410ef855a968fbc40669df1c4a73e' - const indexName = siteVersion == "enterprise" ? 'ghaction' : 'labelstud' - - if(searchInput) { + const appId = "M7RXTHKYPM"; + const apiKey = "8ed23cbc92e0806140603fb62236efee"; + const indexName = + siteVersion == "enterprise" ? "ghaction" : "labelstudiodocs"; + if (searchInput) { window.docsearch({ - container: '#docsearch-input', - inputSelector: '#docsearch-input', + container: "#docsearch-input", + inputSelector: "#docsearch-input", appId, apiKey, indexName, algoliaOptions: { hitsPerPage: 10 }, }); - + const handleFocusSearch = (e) => { - if (document.activeElement.localName === 'body' && e.code !== "Space" && e.code !== "MetaLeft" && !e.altKey && !e.shiftKey && !e.ctrlKey && !e.metaKey) { + if ( + document.activeElement.localName === "body" && + e.code !== "Space" && + e.code !== "MetaLeft" && + !e.altKey && + !e.shiftKey && + !e.ctrlKey && + !e.metaKey + ) { searchInput.focus(); } - if(document.activeElement.localName === 'body' && e.code === "KeyK" && (e.metaKey || e.ctrlKey)) { + if ( + document.activeElement.localName === "body" && + e.code === "KeyK" && + (e.metaKey || e.ctrlKey) + ) { searchInput.focus(); } - } - + }; + window.addEventListener("keydown", handleFocusSearch); } }); @@ -74,26 +101,33 @@ hamburgerButton.classList.toggle("active"); - nav.style.setProperty('display', navStyle.display=== "flex" ? "none" : "flex"); - - }) + nav.style.setProperty( + "display", + navStyle.display === "flex" ? "none" : "flex" + ); + }); - if (window.matchMedia( "(hover: none)" ).matches) { + if (window.matchMedia("(hover: none)").matches) { const toggleQuickNav = (e) => { - if (e.target.tagName.toLowerCase() !== 'a') { + if (e.target.tagName.toLowerCase() !== "a") { const component = e.currentTarget; const menu = component.querySelector("ul"); const menuStyles = getComputedStyle(menu); - menu.style.setProperty('display', menuStyles.display=== "flex" ? "none" : "flex"); + menu.style.setProperty( + "display", + menuStyles.display === "flex" ? "none" : "flex" + ); } - } - - const toggleQuicNavButton = document.querySelector(".page-header-content-switcher"); - toggleQuicNavButton.addEventListener("click", toggleQuickNav) - } + }; + + const toggleQuicNavButton = document.querySelector( + ".page-header-content-switcher" + ); + toggleQuicNavButton.addEventListener("click", toggleQuickNav); + } - pageSidebar.addEventListener('scroll', function() { - localStorage.setItem('labelstudio_scrollPosition', this.scrollTop); + pageSidebar.addEventListener("scroll", function () { + localStorage.setItem("labelstudio_scrollPosition", this.scrollTop); }); })();