From 48241f0842a1e7ed5c8e7b3a9ea5c26435201fe0 Mon Sep 17 00:00:00 2001 From: rogermparent Date: Wed, 9 Mar 2022 22:56:15 -0500 Subject: [PATCH 01/37] Remove plugins and config files moved to theme --- .../custom-yt-embedder.js | 59 --- config/postcss/media.js | 19 - config/postcss/mixins.js | 115 ----- config/prismjs/dvc-commands.js | 71 --- config/prismjs/dvc-hook.js | 29 -- config/prismjs/dvc.js | 64 --- config/prismjs/dvctable.js | 64 --- config/prismjs/usage.js | 21 - plugins/external-link-plugin/index.js | 66 --- plugins/external-link-plugin/package.json | 7 - plugins/gatsby-remark-args-linker/index.js | 100 ---- .../gatsby-remark-args-linker/package.json | 12 - plugins/gatsby-remark-dvc-linker/apiLinker.js | 37 -- .../gatsby-remark-dvc-linker/commandLinker.js | 38 -- plugins/gatsby-remark-dvc-linker/helpers.js | 20 - plugins/gatsby-remark-dvc-linker/index.js | 28 -- .../gatsby-remark-dvc-linker/index.test.js | 70 --- .../gatsby-remark-dvc-linker/liveLinker.js | 29 -- plugins/gatsby-remark-dvc-linker/package.json | 7 - .../gatsby-remark-dvc-linker/simpleLinker.js | 34 -- .../createPages.js | 91 ---- .../gatsby-config.js | 57 --- .../gatsby-node.js | 58 --- plugins/gatsby-theme-iterative-docs/index.js | 1 - .../onCreateNode.js | 49 -- .../gatsby-theme-iterative-docs/package.json | 11 - .../pseudo-shadow.js | 3 - .../gatsby-theme-iterative-docs/redirects.js | 2 - .../gatsby-theme-iterative-docs/sidebar.js | 2 - .../Documentation/Layout/SearchForm/index.tsx | 59 --- .../Layout/SearchForm/styles.module.css | 46 -- .../Layout/SidebarMenu/InnerSidebar/index.tsx | 35 -- .../SidebarMenu/Item/external-link-icon.svg | 1 - .../Layout/SidebarMenu/Item/index.tsx | 143 ------ .../Layout/SidebarMenu/icons/house.svg | 1 - .../Layout/SidebarMenu/icons/index.ts | 9 - .../Layout/SidebarMenu/index.tsx | 80 ---- .../Layout/SidebarMenu/styles.module.css | 118 ----- .../components/Documentation/Layout/index.tsx | 66 --- .../Documentation/Layout/styles.module.css | 113 ----- .../Documentation/Markdown/Main/index.tsx | 111 ----- .../Markdown/Main/styles.module.css | 432 ------------------ .../Markdown/ToggleProvider/index.tsx | 109 ----- .../Markdown/Tooltip/DesktopView/index.tsx | 133 ------ .../Tooltip/DesktopView/styles.module.css | 78 ---- .../Markdown/Tooltip/MobileView/index.tsx | 82 ---- .../Tooltip/MobileView/styles.module.css | 49 -- .../Documentation/Markdown/Tooltip/index.tsx | 59 --- .../Documentation/Markdown/index.tsx | 237 ---------- .../Documentation/Markdown/styles.module.css | 173 ------- .../Documentation/RightPanel/index.tsx | 219 --------- .../RightPanel/styles.module.css | 104 ----- .../Documentation/TutorialsLinks/index.tsx | 46 -- .../TutorialsLinks/styles.module.css | 21 - .../WithJSX/AutoLinkElement/index.tsx | 76 --- .../WithJSX/AutoLinkElement/styles.module.css | 9 - .../Documentation/WithJSX/index.tsx | 38 -- .../src/components/Documentation/index.tsx | 47 -- .../Documentation/styles.module.css | 35 -- .../src/components/HamburgerIcon/index.tsx | 17 - .../HamburgerIcon/styles.module.css | 32 -- .../components/LayoutWidthContainer/index.tsx | 22 - .../LayoutWidthContainer/styles.module.css | 17 - .../src/components/Link/index.tsx | 136 ------ .../src/components/SEO/helper.ts | 83 ---- .../src/components/SEO/index.tsx | 80 ---- .../src/components/ShowOnly/index.tsx | 20 - .../src/components/ShowOnly/styles.module.css | 15 - .../src/components/SocialIcon/discord.svg | 3 - .../src/components/SocialIcon/github.svg | 1 - .../src/components/SocialIcon/index.tsx | 51 --- .../components/SocialIcon/linkedin-no-bg.svg | 3 - .../src/components/SocialIcon/linkedin.svg | 1 - .../src/components/SocialIcon/twitter.svg | 1 - .../src/components/SocialIcon/youtube.svg | 3 - .../src/config/custom-media.js | 19 - .../src/constants.ts | 1 - .../src/getGithubLink.ts | 3 - .../src/queries/siteMeta.ts | 29 -- .../src/templates/doc.tsx | 62 --- .../src/utils/front/accessibility.ts | 14 - .../src/utils/front/api.ts | 102 ----- .../src/utils/front/breakpoints.ts | 12 - .../src/utils/front/customProperties.ts | 31 -- .../src/utils/front/focusElementWithHotkey.ts | 21 - .../src/utils/front/glossary.ts | 25 - .../src/utils/front/i18n.ts | 23 - .../src/utils/front/images.ts | 28 -- .../src/utils/front/isClient.ts | 12 - .../src/utils/front/keyboard.ts | 9 - .../src/utils/front/plausible.ts | 21 - .../src/utils/front/resources.ts | 64 --- .../src/utils/front/safeQuerySelector.ts | 10 - .../src/utils/front/scroll.ts | 81 ---- .../src/utils/front/useCustomYtEmbeds.ts | 61 --- .../src/utils/shared/redirects.js | 96 ---- .../src/utils/shared/redirects.test.js | 248 ---------- .../src/utils/shared/sidebar.js | 236 ---------- .../src/utils/shared/sidebar.test.js | 400 ---------------- .../src/utils/shared/tagToSlug.js | 2 - plugins/resize-image-plugin/constants.js | 5 - plugins/resize-image-plugin/index.js | 126 ----- plugins/resize-image-plugin/index.test.js | 40 -- plugins/resize-image-plugin/package.json | 7 - plugins/utils/convertHast.js | 17 - plugins/utils/makeFeedHtml.js | 53 --- 106 files changed, 6236 deletions(-) delete mode 100644 config/gatsby-remark-embedder/custom-yt-embedder.js delete mode 100644 config/postcss/media.js delete mode 100644 config/postcss/mixins.js delete mode 100644 config/prismjs/dvc-commands.js delete mode 100644 config/prismjs/dvc-hook.js delete mode 100644 config/prismjs/dvc.js delete mode 100644 config/prismjs/dvctable.js delete mode 100644 config/prismjs/usage.js delete mode 100644 plugins/external-link-plugin/index.js delete mode 100644 plugins/external-link-plugin/package.json delete mode 100644 plugins/gatsby-remark-args-linker/index.js delete mode 100644 plugins/gatsby-remark-args-linker/package.json delete mode 100644 plugins/gatsby-remark-dvc-linker/apiLinker.js delete mode 100644 plugins/gatsby-remark-dvc-linker/commandLinker.js delete mode 100644 plugins/gatsby-remark-dvc-linker/helpers.js delete mode 100644 plugins/gatsby-remark-dvc-linker/index.js delete mode 100644 plugins/gatsby-remark-dvc-linker/index.test.js delete mode 100644 plugins/gatsby-remark-dvc-linker/liveLinker.js delete mode 100644 plugins/gatsby-remark-dvc-linker/package.json delete mode 100644 plugins/gatsby-remark-dvc-linker/simpleLinker.js delete mode 100644 plugins/gatsby-theme-iterative-docs/createPages.js delete mode 100644 plugins/gatsby-theme-iterative-docs/gatsby-config.js delete mode 100644 plugins/gatsby-theme-iterative-docs/gatsby-node.js delete mode 100644 plugins/gatsby-theme-iterative-docs/index.js delete mode 100644 plugins/gatsby-theme-iterative-docs/onCreateNode.js delete mode 100644 plugins/gatsby-theme-iterative-docs/package.json delete mode 100644 plugins/gatsby-theme-iterative-docs/pseudo-shadow.js delete mode 100644 plugins/gatsby-theme-iterative-docs/redirects.js delete mode 100644 plugins/gatsby-theme-iterative-docs/sidebar.js delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SearchForm/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SearchForm/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/InnerSidebar/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/Item/external-link-icon.svg delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/Item/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/icons/house.svg delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/icons/index.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Main/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Main/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/ToggleProvider/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/DesktopView/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/DesktopView/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/MobileView/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/MobileView/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/RightPanel/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/RightPanel/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/TutorialsLinks/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/TutorialsLinks/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/AutoLinkElement/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/AutoLinkElement/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Documentation/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/HamburgerIcon/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/HamburgerIcon/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/LayoutWidthContainer/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/LayoutWidthContainer/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/Link/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/SEO/helper.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/SEO/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/ShowOnly/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/ShowOnly/styles.module.css delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/discord.svg delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/github.svg delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/index.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/linkedin-no-bg.svg delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/linkedin.svg delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/twitter.svg delete mode 100644 plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/youtube.svg delete mode 100644 plugins/gatsby-theme-iterative-docs/src/config/custom-media.js delete mode 100644 plugins/gatsby-theme-iterative-docs/src/constants.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/getGithubLink.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/queries/siteMeta.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/templates/doc.tsx delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/accessibility.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/api.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/breakpoints.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/customProperties.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/focusElementWithHotkey.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/glossary.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/i18n.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/images.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/isClient.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/keyboard.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/plausible.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/resources.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/safeQuerySelector.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/scroll.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/front/useCustomYtEmbeds.ts delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/shared/redirects.js delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/shared/redirects.test.js delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar.js delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar.test.js delete mode 100644 plugins/gatsby-theme-iterative-docs/src/utils/shared/tagToSlug.js delete mode 100644 plugins/resize-image-plugin/constants.js delete mode 100644 plugins/resize-image-plugin/index.js delete mode 100644 plugins/resize-image-plugin/index.test.js delete mode 100644 plugins/resize-image-plugin/package.json delete mode 100644 plugins/utils/convertHast.js delete mode 100644 plugins/utils/makeFeedHtml.js diff --git a/config/gatsby-remark-embedder/custom-yt-embedder.js b/config/gatsby-remark-embedder/custom-yt-embedder.js deleted file mode 100644 index 7acf6a2d10..0000000000 --- a/config/gatsby-remark-embedder/custom-yt-embedder.js +++ /dev/null @@ -1,59 +0,0 @@ -const shouldTransform = url => { - const { host, pathname, searchParams } = new URL(url) - - return ( - host === 'youtu.be' || - (['youtube.com', 'www.youtube.com'].includes(host) && - pathname.includes('/watch') && - Boolean(searchParams.get('v'))) - ) -} - -const getTimeValueInSeconds = timeValue => { - if (Number(timeValue).toString() === timeValue) { - return timeValue - } - - const { - 1: hours = '0', - 2: minutes = '0', - 3: seconds = '0' - } = timeValue.match(/(?:(\d*)h)?(?:(\d*)m)?(?:(\d*)s)?/) - - return String((Number(hours) * 60 + Number(minutes)) * 60 + Number(seconds)) -} - -const getYouTubeIFrameSrc = urlString => { - const url = new URL(urlString) - const id = - url.host === 'youtu.be' ? url.pathname.slice(1) : url.searchParams.get('v') - - const embedUrl = new URL( - `https://www.youtube-nocookie.com/embed/${id}?rel=0&&showinfo=0;` - ) - - url.searchParams.forEach((value, name) => { - if (name === 'v') { - return - } - - if (name === 't') { - embedUrl.searchParams.append('start', getTimeValueInSeconds(value)) - } else { - embedUrl.searchParams.append(name, value) - } - }) - return embedUrl.toString() -} - -// all code above taken from gatsby-remark-embedder (https://github.com/MichaelDeBoey/gatsby-remark-embedder) - -const name = 'YouTubeCustom' - -const getHTML = url => { - const iframeSrc = getYouTubeIFrameSrc(url) - - return `
By clicking play, you agree to YouTube's Privacy Policy and Terms of Service
` -} - -module.exports = { getHTML, name, shouldTransform } diff --git a/config/postcss/media.js b/config/postcss/media.js deleted file mode 100644 index 1e30babccc..0000000000 --- a/config/postcss/media.js +++ /dev/null @@ -1,19 +0,0 @@ -const screens = { - giant: 1200, - desktop: 1005, - tablet: 768, - phablet: 572, - phone: 376 -} - -module.exports = { - screens, - customMedia: { - '--xxs-scr': `(max-width: ${screens.phone}px)`, - '--xs-scr': `(max-width: ${screens.phablet}px)`, - '--sm-scr': `(max-width: ${screens.tablet}px)`, - '--md-scr': `(max-width: ${screens.desktop - 1}px)`, - '--lg-scr': `(min-width: ${screens.desktop}px)`, - '--xl-scr': `(min-width: ${screens.giant}px)` - } -} diff --git a/config/postcss/mixins.js b/config/postcss/mixins.js deleted file mode 100644 index 299dac9472..0000000000 --- a/config/postcss/mixins.js +++ /dev/null @@ -1,115 +0,0 @@ -const { customMedia } = require('./media') - -const focus = { - '&:focus': { - color: 'var(--color-orange)' - } -} - -const active = { - '&:active': { - position: 'relative', - top: '1px', - left: '1px' - } -} - -const hover = { - '&:hover': { - opacity: 0.7 - } -} - -module.exports = { - mixins: { - 'h1-desktop': { - 'font-weight': '500', - 'font-size': '40px', - 'line-height': '60px' - }, - 'h1-mobile': { - 'font-weight': '500', - 'font-size': '30px', - 'line-height': '40px' - }, - 'h2-desktop': { - 'font-weight': '500', - 'font-size': '30px', - 'line-height': '40px' - }, - 'h2-mobile': { - 'font-weight': '500', - 'font-size': '25px', - 'line-height': '35px' - }, - 'h3-desktop': { - 'font-weight': '500', - 'font-size': '24px', - 'line-height': '34px' - }, - 'h3-mobile': { - 'font-weight': '500', - 'font-size': '20px', - 'line-height': '30px' - }, - 'text-desktop': { - 'font-size': '24px', - 'line-height': '34px' - }, - 'text-mobile': { - 'font-size': '20px', - 'line-height': '30px' - }, - 'text-diminished': { - 'font-size': '20px', - 'line-height': '30px' - }, - 'text-secondary': { - 'font-size': '16px', - 'line-height': '24px' - }, - 'button-big': { - 'font-size': '20px', - 'line-height': '30px' - }, - 'button-small': { - 'font-size': '16px', - 'line-height': '25px' - }, - columns: { - display: 'flex', - 'flex-direction': 'row', - 'flex-flow': 'wrap', - 'justify-content': 'space-between', - - [`@media ${customMedia['--sm-scr']}`]: { - 'flex-direction': 'row' - }, - - [`@media ${customMedia['--xs-scr']}`]: { - 'justify-content': 'center' - } - }, - column: { - 'flex-basis': '33.3%', - - [`@media ${customMedia['--sm-scr']}`]: { - 'flex-basis': '50%' - }, - - [`@media ${customMedia['--xs-scr']}`]: { - 'flex-basis': '100%' - } - }, - link: { - 'text-decoration': 'none', - color: 'var(--color-blue)', - ...hover, - ...focus, - ...active - }, - hover, - focus, - active - } -} diff --git a/config/prismjs/dvc-commands.js b/config/prismjs/dvc-commands.js deleted file mode 100644 index afd9bc0c1d..0000000000 --- a/config/prismjs/dvc-commands.js +++ /dev/null @@ -1,71 +0,0 @@ -/* eslint-env node */ - -module.exports = [ - 'version', - 'update', - 'unprotect', - 'unfreeze', - 'tag', - 'status', - 'stage list', - 'stage add', - 'stage', - 'run', - 'root', - 'repro', - 'remove', - 'remote rename', - 'remote remove', - 'remote modify', - 'remote list', - 'remote default', - 'remote add', - 'remote', - 'push', - 'pull', - 'pkg', - 'plots show', - 'plots modify', - 'plots diff', - 'plots', - 'move', - 'metrics show', - 'metrics diff', - 'metrics', - 'params diff', - 'params', - 'ls', - 'list', - 'install', - 'init', - 'import-url', - 'import', - 'help', - 'get-url', - 'get', - 'gc', - 'freeze', - 'fetch', - 'exp show', - 'exp run', - 'exp remove', - 'exp push', - 'exp pull', - 'exp gc', - 'exp diff', - 'exp branch', - 'exp apply', - 'exp', - 'experiments', - 'doctor', - 'diff', - 'destroy', - 'dag', - 'config', - 'commit', - 'checkout', - 'check-ignore', - 'cache dir', - 'cache', - 'add' -] diff --git a/config/prismjs/dvc-hook.js b/config/prismjs/dvc-hook.js deleted file mode 100644 index 44784a522b..0000000000 --- a/config/prismjs/dvc-hook.js +++ /dev/null @@ -1,29 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -/* eslint-env node */ - -const Prism = require('prismjs') -const argsRegex = new RegExp(/\-{1,2}[a-zA-Z-]*/, 'ig') - -// Make sure the $ part of the command prompt in shell -// examples isn't copiable by making it an 'input' token. -Prism.hooks.add('after-tokenize', env => { - if (env.language !== 'dvc') { - return - } - - for (const token of env.tokens) { - if (token.type === 'line' && /^\$\s+$/.test(token.content[0])) { - const old = token.content[0] - token.content[0] = new Prism.Token('input', old, null, old, false) - } - } -}) - -Prism.hooks.add('wrap', env => { - if (env.language === 'usage' && env.type === 'arg') { - const { content } = env - env.tag = 'a' - const href = content.match(argsRegex)[0] - env.attributes.href = `#${href}` - } -}) diff --git a/config/prismjs/dvc.js b/config/prismjs/dvc.js deleted file mode 100644 index 39b3eb5c17..0000000000 --- a/config/prismjs/dvc.js +++ /dev/null @@ -1,64 +0,0 @@ -/* eslint-env node */ - -// we require prism and load its bash module so we have -// Prism.languages.bash to embed into our DVC language. - -const Prism = require('prismjs') -require('prismjs/components/prism-bash') -require('./dvc-hook') -const { bash } = Prism.languages - -const dvc = require('./dvc-commands') - -// Command arrays are intentionally reverse sorted -// to prevent shorter matches before longer ones - -const git = [ - 'tag', - 'status', - 'remote update', - 'remote rename', - 'remote remove', - 'remote add', - 'remote', - 'push', - 'pull', - 'merge', - 'init', - 'fetch', - 'commit', - 'clone', - 'checkout', - 'add' -] - -const beforeCommand = String.raw`(\$[\s(]+|;\s*)` - -Prism.languages.dvc = { - line: { - pattern: /(?<=(^|\n))\$[\s\S]*?[^\\](:?\n|$)/, - inside: { - dvc: { - pattern: new RegExp( - String.raw`${beforeCommand}\b(?:dvc (?:${dvc.join('|')}))\b` - ), - greedy: true, - lookbehind: true - }, - git: { - pattern: new RegExp( - String.raw`${beforeCommand}\b(?:git (?:${git.join('|')}))\b` - ), - greedy: true, - lookbehind: true - }, - command: { - pattern: new RegExp(String.raw`${beforeCommand}\b[a-zA-Z0-9\-_]+\b`), - greedy: true, - lookbehind: true - }, - ...bash - } - }, - comment: bash.comment -} diff --git a/config/prismjs/dvctable.js b/config/prismjs/dvctable.js deleted file mode 100644 index 4121762144..0000000000 --- a/config/prismjs/dvctable.js +++ /dev/null @@ -1,64 +0,0 @@ -/* eslint-env node */ -const Prism = require('prismjs') - -const getTableTextBgColorRegex = color => new RegExp(String.raw`${color}:\S+`) - -const boldAndItalicConfig = { - bold: { - pattern: /\*\*(?:(?!\*\*).)+\*\*/, - inside: { - hide: /\*\*/ - } - }, - italic: { - pattern: /\*(?:(?!\*).)+\*/, - inside: { - hide: /\*/ - } - } -} - -Prism.languages.dvctable = { - rows: { - pattern: /((?<=^|\n)[^─]{2}[\s\S]*?(:?\n|$))+/, - inside: { - 'bg-white': { - pattern: getTableTextBgColorRegex('(white|neutral)'), - inside: { - hide: { - pattern: /(white|neutral):/ - }, - ...boldAndItalicConfig - } - }, - 'bg-yellow': { - pattern: getTableTextBgColorRegex('(yellow|metric)'), - inside: { - hide: { - pattern: /(yellow|metric):/ - }, - ...boldAndItalicConfig - } - }, - 'bg-blue': { - pattern: getTableTextBgColorRegex('(blue|param)'), - inside: { - hide: { - pattern: /(blue|param):/ - }, - ...boldAndItalicConfig - } - }, - 'bg-violet': { - pattern: getTableTextBgColorRegex('(violet|dep)'), - inside: { - hide: { - pattern: /(violet|dep):/ - }, - ...boldAndItalicConfig - } - }, - ...boldAndItalicConfig - } - } -} diff --git a/config/prismjs/usage.js b/config/prismjs/usage.js deleted file mode 100644 index e0a7fe53c9..0000000000 --- a/config/prismjs/usage.js +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-env node */ - -const dvc = require('./dvc-commands') -const Prism = require('prismjs') - -Prism.languages.usage = { - dvc: { - pattern: new RegExp(`dvc (?:${dvc.join('|')})`) - }, - usage: { - pattern: /(^|\n)\s*(usage|positional arguments|optional arguments)/ - }, - args: { - pattern: /(?<=\[)(?:[^\]\[]+|\[(?:[^\]\[]+|\[[^\]\[]*\])*\])*(?=\])/, - inside: { - arg: { - pattern: /\-{1,2}[^|]*/ - } - } - } -} diff --git a/plugins/external-link-plugin/index.js b/plugins/external-link-plugin/index.js deleted file mode 100644 index dd3aa59cea..0000000000 --- a/plugins/external-link-plugin/index.js +++ /dev/null @@ -1,66 +0,0 @@ -const visit = require('unist-util-visit') -const { selectAll } = require('hast-util-select') -const escape = require('escape-html') - -const { convertHastToHtml, convertHtmlToHast } = require('../utils/convertHast') - -const requiredExternalLinkAttrs = ['href', 'title', 'description', 'link'] - -function isCorrectExternalLinkAttr(attrsKeyTagArray) { - return requiredExternalLinkAttrs.every(attr => - attrsKeyTagArray.includes(attr) - ) -} - -function renderTag(attrs) { - return ` -
- -
-

${escape(attrs.title)}

-
${escape(attrs.description)}
- -
- ${ - attrs.image - ? `
- ${escape(attrs.title)} -
` - : `` - } -
-
- ` -} - -module.exports = ({ markdownAST }) => { - visit(markdownAST, 'html', node => { - const hast = convertHtmlToHast(node.value) - const externalLinkNodeList = selectAll('external-link', hast) - - if (!externalLinkNodeList.length) { - return - } - - externalLinkNodeList.forEach(externalLinkNode => { - const { properties } = externalLinkNode - if (isCorrectExternalLinkAttr(Object.keys(properties))) { - const externalLinkHtml = renderTag(properties) - const externalLinkHast = convertHtmlToHast(externalLinkHtml) - - externalLinkNode.type = externalLinkHast.type - externalLinkNode.tagName = externalLinkHast.tagName - externalLinkNode.properties = externalLinkHast.properties - externalLinkNode.children = externalLinkHast.children - } else { - throw new Error( - `No correct tag or not all nested tags in ${node.value}` - ) - } - }) - - node.value = convertHastToHtml(hast) - }) -} diff --git a/plugins/external-link-plugin/package.json b/plugins/external-link-plugin/package.json deleted file mode 100644 index 39300d0e85..0000000000 --- a/plugins/external-link-plugin/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "external-link-plugin", - "version": "1.0.0", - "main": "index.js", - "author": "Ilja Bykovskij", - "license": "Apache-2.0" -} diff --git a/plugins/gatsby-remark-args-linker/index.js b/plugins/gatsby-remark-args-linker/index.js deleted file mode 100644 index b6fe786ee5..0000000000 --- a/plugins/gatsby-remark-args-linker/index.js +++ /dev/null @@ -1,100 +0,0 @@ -const visit = require('unist-util-visit') -const _ = require('lodash') - -const argsRegex = new RegExp(/\-{1,2}[a-zA-Z-]*/, 'ig') - -function patch(context, key, value) { - if (!_.has(context, key)) { - context[key] = value - } - - return context[key] -} - -const addIdAttrToNode = (node, id) => { - const data = patch(node, `data`, {}) - - patch(data, `id`, id) - patch(data, `htmlAttributes`, {}) - patch(data, `hProperties`, {}) - patch(data.htmlAttributes, `id`, id) - patch(data.hProperties, `id`, id) -} - -module.exports = ( - { markdownAST, getNode, markdownNode }, - { icon = '', className = 'anchor', isIconAfterHeader = false, pathname = '' } -) => { - if (!pathname) return markdownAST - const parentNode = getNode(markdownNode.parent) - let isPath = - typeof pathname === 'string' - ? parentNode.relativeDirectory.startsWith(pathname) - : Array.isArray(pathname) - ? pathname.some(p => parentNode.relativeDirectory.startsWith(p)) - : false - if (!isPath) return markdownAST - visit( - markdownAST, - node => - node.type === 'listItem' && - node.children[0]?.type === 'paragraph' && - node.children[0]?.children[0]?.type === 'inlineCode' && - String(node.children[0].children[0]?.value).startsWith('-'), - listItemNode => { - const isParagraphNode = listItemNode.children?.[0].type === 'paragraph' - if (!isParagraphNode) return - const paragraphNode = listItemNode.children[0] - const isFirstArgNode = - paragraphNode.children[0]?.type === 'inlineCode' && - String(paragraphNode.children[0]?.value).startsWith('-') - if (isFirstArgNode) { - const firstArgNode = paragraphNode.children[0] - const value = firstArgNode.value - const id = value.match(argsRegex)[0] - addIdAttrToNode(firstArgNode, id) - - const data = patch(listItemNode, `data`, {}) - patch(data, `htmlAttributes`, {}) - patch(data, `hProperties`, {}) - if (icon) { - patch(data.hProperties, `style`, `position:relative;`) - const label = id.split(`-`).join(` `) - const method = isIconAfterHeader ? `push` : `unshift` - listItemNode.children[method]({ - type: `link`, - url: `#${id}`, - title: null, - children: [], - data: { - hProperties: { - 'aria-label': `option ${label.trim()} permalink`, - class: `${className} ${isIconAfterHeader ? `after` : `before`}` - }, - hChildren: [ - { - type: `raw`, - // The Octicon link icon is the default. But users can set their own icon via the "icon" option. - value: icon - } - ] - } - }) - } - - const isSecondArgNode = - String(paragraphNode.children[1]?.value).trim() === ',' && - paragraphNode.children[2]?.type === 'inlineCode' && - String(paragraphNode.children[2].value).startsWith('-') - if (isSecondArgNode) { - const secondArgNode = paragraphNode.children[2] - const value = secondArgNode.value - const id = value.match(argsRegex)[0] - addIdAttrToNode(secondArgNode, id) - } - } - } - ) - // Manipulate AST - return markdownAST -} diff --git a/plugins/gatsby-remark-args-linker/package.json b/plugins/gatsby-remark-args-linker/package.json deleted file mode 100644 index 9c42ad4759..0000000000 --- a/plugins/gatsby-remark-args-linker/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "gatsby-remark-args-linker", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC" -} diff --git a/plugins/gatsby-remark-dvc-linker/apiLinker.js b/plugins/gatsby-remark-dvc-linker/apiLinker.js deleted file mode 100644 index c54d0526b5..0000000000 --- a/plugins/gatsby-remark-dvc-linker/apiLinker.js +++ /dev/null @@ -1,37 +0,0 @@ -/* eslint-env node */ - -const { createLinkNode } = require('./helpers') -const { - getItemByPath -} = require('../../plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar') - -const DVC_API_REGEXP = /dvc.api([a-z-._]*\(\)$)?/ -const METHOD_REGEXP = /^[a-z-._]*\(\)$/ -const API_ROOT = '/doc/api-reference/' - -module.exports = astNode => { - const node = astNode[0] - const parent = astNode[2] - - if (parent.type !== 'link' && DVC_API_REGEXP.test(node.value)) { - const parts = node.value.split('.') - let url - - const isMethod = parts[2] && METHOD_REGEXP.test(parts[2]) - const method = isMethod && parts[2].slice(0, -2) - const isRoot = parts[0] === 'dvc' && parts[1] === 'api' && !parts[2] - - if (isRoot) { - url = `${API_ROOT}` - } else { - url = `${API_ROOT}${method}` - } - - const isMethodPageExists = getItemByPath(url) - if (isMethodPageExists) { - createLinkNode(url, astNode) - } - } - - return astNode -} diff --git a/plugins/gatsby-remark-dvc-linker/commandLinker.js b/plugins/gatsby-remark-dvc-linker/commandLinker.js deleted file mode 100644 index 17c28b2246..0000000000 --- a/plugins/gatsby-remark-dvc-linker/commandLinker.js +++ /dev/null @@ -1,38 +0,0 @@ -/* eslint-env node */ - -const { createLinkNode } = require('./helpers') -const { - getItemByPath -} = require('../../plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar') - -const DVC_REGEXP = /dvc\s+[a-z][a-z-.]*/ -const COMMAND_REGEXP = /^[a-z][a-z-]*$/ -const ARGS_REGEXP = new RegExp(/\-{1,2}[a-zA-Z-]*/, 'ig') -const COMMAND_ROOT = '/doc/command-reference/' - -module.exports = astNode => { - const node = astNode[0] - const parent = astNode[2] - if (parent.type !== 'link' && DVC_REGEXP.test(node.value)) { - const parts = node.value.split(/\s+/) - const index = parts.findIndex(part => String(part).trim() === 'dvc') - const command = parts[index + 1] - const baseUrl = `${COMMAND_ROOT}${command}` - let url - const isCommandPageExists = getItemByPath(baseUrl) - if (isCommandPageExists) { - url = baseUrl - for (const arg of parts.slice(index + 2)) { - if (arg && COMMAND_REGEXP.test(arg) && getItemByPath(`${url}/${arg}`)) { - url = `${url}/${arg}` - } else if (arg && ARGS_REGEXP.test(arg)) { - const id = arg.match(ARGS_REGEXP)[0] - url = `${url}#${id}` - break - } - } - createLinkNode(url, astNode) - } - } - return astNode -} diff --git a/plugins/gatsby-remark-dvc-linker/helpers.js b/plugins/gatsby-remark-dvc-linker/helpers.js deleted file mode 100644 index 18f9cf38d0..0000000000 --- a/plugins/gatsby-remark-dvc-linker/helpers.js +++ /dev/null @@ -1,20 +0,0 @@ -const unified = require('unified') -const remarkHtml = require('remark-html') -const remarkParse = require('remark-parse') -const removePosition = require('unist-util-remove-position') - -// We do not need to consider the position of the AST nodes -const buildAst = mdToBuild => - removePosition(unified().use(remarkHtml).use(remarkParse).parse(mdToBuild)) - -const createLinkNode = (url, [node, index, parent]) => - url && - (parent.children[index] = { - type: 'link', - url, - title: null, - children: [node], - position: node.position - }) - -module.exports = { buildAst, createLinkNode } diff --git a/plugins/gatsby-remark-dvc-linker/index.js b/plugins/gatsby-remark-dvc-linker/index.js deleted file mode 100644 index 70f449b9b3..0000000000 --- a/plugins/gatsby-remark-dvc-linker/index.js +++ /dev/null @@ -1,28 +0,0 @@ -/* eslint-env node */ - -const flow = require('lodash/flow') -const constant = require('lodash/constant') -const visit = require('unist-util-visit') - -const apiLinker = require('./apiLinker') -const commandLinker = require('./commandLinker') -const liveLinker = require('./liveLinker') -const simpleLinker = require('./simpleLinker') - -// Lifting up the AST visitor in order not to repeat the -// calculations times the amount of linkers we have -module.exports = ({ markdownAST }) => { - visit( - markdownAST, - 'inlineCode', - flow([ - Array, - liveLinker, - commandLinker, - apiLinker, - simpleLinker, - constant(undefined) - ]) - ) - return markdownAST -} diff --git a/plugins/gatsby-remark-dvc-linker/index.test.js b/plugins/gatsby-remark-dvc-linker/index.test.js deleted file mode 100644 index 4cc73689cb..0000000000 --- a/plugins/gatsby-remark-dvc-linker/index.test.js +++ /dev/null @@ -1,70 +0,0 @@ -const flow = require('lodash/flow') -const constant = require('lodash/constant') -const visit = require('unist-util-visit') - -const gatsbyRemarkDvcLinker = require('.') -const apiLinker = require('./apiLinker') -const commandLinker = require('./commandLinker') -const liveLinker = require('./liveLinker') - -const { buildAst } = require('./helpers') - -describe('gatsby-remark-dvc-linker', () => { - api = { - inlineCode: '`dvc.api.get_url()`', - url: '[`dvc.api.get_url()`](/doc/api-reference/get_url)' - } - - apiRoot = { - inlineCode: '`dvc.api`', - url: '[`dvc.api`](/doc/api-reference/)' - } - - command = { - inlineCode: '`dvc get`', - url: '[`dvc get`](/doc/command-reference/get)' - } - - live = { - inlineCode: '`Live.log()`', - url: '[`Live.log()`](/doc/dvclive/api-reference/live/log)' - } - - it('composes apiLinker and commandLinker', () => { - const ast = buildAst(`${api.inlineCode} ${command.inlineCode}`) - gatsbyRemarkDvcLinker({ markdownAST: ast }) - expect(ast).toEqual(buildAst(`${api.url} ${command.url}`)) - }) - - it('transforms DVCLive API reference to a link', () => { - const ast = buildAst(live.inlineCode) - visit(ast, 'inlineCode', flow([Array, liveLinker, constant(undefined)])) - expect(ast).toEqual(buildAst(live.url)) - }) - - describe('apiLinker', () => { - it('transforms API reference to a link', () => { - const ast = buildAst(api.inlineCode) - visit(ast, 'inlineCode', flow([Array, apiLinker, constant(undefined)])) - expect(ast).toEqual(buildAst(api.url)) - }) - - it('transforms root API reference to a link', () => { - const ast = buildAst(apiRoot.inlineCode) - visit(ast, 'inlineCode', flow([Array, apiLinker, constant(undefined)])) - expect(ast).toEqual(buildAst(apiRoot.url)) - }) - }) - - describe('commandLinker', () => { - it('transforms command reference to a link', () => { - const ast = buildAst(command.inlineCode) - visit( - ast, - 'inlineCode', - flow([Array, commandLinker, constant(undefined)]) - ) - expect(ast).toEqual(buildAst(command.url)) - }) - }) -}) diff --git a/plugins/gatsby-remark-dvc-linker/liveLinker.js b/plugins/gatsby-remark-dvc-linker/liveLinker.js deleted file mode 100644 index 34c3a01a19..0000000000 --- a/plugins/gatsby-remark-dvc-linker/liveLinker.js +++ /dev/null @@ -1,29 +0,0 @@ -/* eslint-env node */ - -const { createLinkNode } = require('./helpers') -const { - getItemByPath -} = require('../../plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar') - -const LIVE_API_REGEXP = /Live.([a-z-._]*\(\)$)?/ -const METHOD_REGEXP = /^[a-z-._]*\(\)$/ -const API_ROOT = '/doc/dvclive/api-reference/live/' - -module.exports = astNode => { - const node = astNode[0] - const parent = astNode[2] - - if (parent.type !== 'link' && LIVE_API_REGEXP.test(node.value)) { - const parts = node.value.split('.') - const isMethod = parts[1] && METHOD_REGEXP.test(parts[1]) - const method = isMethod && parts[1].slice(0, -2) - const url = `${API_ROOT}${method}` - - const isMethodPageExists = getItemByPath(url) - if (isMethodPageExists) { - createLinkNode(url, astNode) - } - } - - return astNode -} diff --git a/plugins/gatsby-remark-dvc-linker/package.json b/plugins/gatsby-remark-dvc-linker/package.json deleted file mode 100644 index 92bd7b6711..0000000000 --- a/plugins/gatsby-remark-dvc-linker/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "gatsby-remark-dvc-linker", - "version": "1.0.1", - "main": "index.js", - "author": "Ivan Shcheklein", - "license": "Apache-2.0" -} diff --git a/plugins/gatsby-remark-dvc-linker/simpleLinker.js b/plugins/gatsby-remark-dvc-linker/simpleLinker.js deleted file mode 100644 index 46e2fa8678..0000000000 --- a/plugins/gatsby-remark-dvc-linker/simpleLinker.js +++ /dev/null @@ -1,34 +0,0 @@ -/* eslint-env node */ - -const { createLinkNode } = require('./helpers') - -const entries = require('../../content/linked-terms') - -const excludedParentTypes = ['link', 'heading'] - -const useMatcher = (matcher, item) => { - switch (typeof matcher) { - case 'string': - return item === matcher - case 'object': - if (Array.isArray(matcher)) - return matcher.find(submatcher => useMatcher(submatcher, item)) - if (matcher instanceof RegExp) return matcher.match(item) - default: - throw `gatsby-remark-dvc-linker simpleLinker given bad matcher of type "${typeof matcher}"` - } -} - -module.exports = astNode => { - const node = astNode[0] - const parent = astNode[2] - - if (!excludedParentTypes.includes(parent.type)) { - const entry = entries.find(({ matches }) => useMatcher(matches, node.value)) - if (entry) { - createLinkNode(entry.url, astNode) - } - } - - return astNode -} diff --git a/plugins/gatsby-theme-iterative-docs/createPages.js b/plugins/gatsby-theme-iterative-docs/createPages.js deleted file mode 100644 index 50595b62b8..0000000000 --- a/plugins/gatsby-theme-iterative-docs/createPages.js +++ /dev/null @@ -1,91 +0,0 @@ -const GithubSlugger = require('github-slugger') - -const slugger = new GithubSlugger() -const SLUG_REGEXP = /\s+{#([a-z0-9-]*[a-z0-9]+)}\s*$/ - -const extractSlugFromTitle = title => { - // extracts expressions like {#too-many-files} from the end of a title - const meta = title.match(SLUG_REGEXP) - - if (meta) { - return [title.substring(0, meta.index), meta[1]] - } - return [title, slugger.slug(title)] -} - -const parseHeadings = text => { - const headingRegex = /\n(## \s*)(.*)/g - const matches = [] - let match - do { - match = headingRegex.exec(text) - if (match) { - const [title, slug] = extractSlugFromTitle(match[2]) - matches.push({ - text: title, - slug: slug - }) - } - } while (match) - - slugger.reset() - return matches -} - -const createPages = async ( - { graphql, actions }, - { defaultTemplate, getTemplate, disable } -) => { - if (disable) return - const docsResponse = await graphql( - ` - { - docs: allDocsPage(limit: 9999) { - edges { - node { - id - slug - template - parent { - ... on MarkdownRemark { - rawMarkdownBody - } - } - } - } - } - } - ` - ) - - if (docsResponse.errors) { - throw docsResponse.errors - } - - docsResponse.data.docs.edges.forEach(doc => { - const { - node: { - id, - slug, - template, - parent: { rawMarkdownBody } - } - } = doc - const headings = parseHeadings(rawMarkdownBody) - - if (slug) { - actions.createPage({ - component: getTemplate(template, defaultTemplate), - path: slug, - context: { - id, - slug, - isDocs: true, - headings - } - }) - } - }) -} - -module.exports = createPages diff --git a/plugins/gatsby-theme-iterative-docs/gatsby-config.js b/plugins/gatsby-theme-iterative-docs/gatsby-config.js deleted file mode 100644 index 1176dc1dfe..0000000000 --- a/plugins/gatsby-theme-iterative-docs/gatsby-config.js +++ /dev/null @@ -1,57 +0,0 @@ -module.exports = ({ remark }) => { - const plugins = [] - if (remark) { - plugins.push({ - resolve: 'gatsby-transformer-remark', - options: { - plugins: [ - 'gatsby-remark-embedder', - { - resolve: 'gatsby-remark-prismjs', - options: { - noInlineHighlight: true, - languageExtensions: [ - { - language: 'text', - definition: {} - } - ] - } - }, - { - resolve: 'gatsby-remark-smartypants', - options: { - quotes: false - } - }, - { - resolve: 'gatsby-remark-embed-gist', - options: { - includeDefaultCss: true - } - }, - 'gatsby-remark-relative-images', - 'gatsby-remark-copy-linked-files', - 'gatsby-remark-external-links', - { - resolve: 'gatsby-remark-autolink-headers', - options: { - enableCustomId: true, - isIconAfterHeader: true - } - }, - { - resolve: 'gatsby-remark-images', - options: { - withWebp: true - } - }, - 'gatsby-remark-responsive-iframe' - ] - } - }) - } - return { - plugins - } -} diff --git a/plugins/gatsby-theme-iterative-docs/gatsby-node.js b/plugins/gatsby-theme-iterative-docs/gatsby-node.js deleted file mode 100644 index 49274bfe64..0000000000 --- a/plugins/gatsby-theme-iterative-docs/gatsby-node.js +++ /dev/null @@ -1,58 +0,0 @@ -const path = require('path') - -const defaultGetTemplate = (template, defaultTemplate) => - template - ? require.resolve(path.resolve('src', 'templates', template + '.tsx')) - : defaultTemplate - -exports.pluginOptionsSchema = ({ Joi }) => { - return Joi.object({ - disable: Joi.boolean().default(Boolean(process.env.SKIP_DOCS)), - getTemplate: Joi.function().default(() => defaultGetTemplate), - defaultTemplate: Joi.string().default( - require.resolve('./src/templates/doc.tsx') - ), - remark: Joi.boolean().default(true) - }) -} - -exports.createSchemaCustomization = async api => { - const { - actions: { createTypes }, - schema: { buildObjectType } - } = api - createTypes([ - buildObjectType({ - name: 'DocsPage', - interfaces: ['Node'], - fields: { - template: 'String', - title: 'String', - description: 'String' - } - }) - ]) -} - -exports.onCreateWebpackConfig = ({ actions }) => { - actions.setWebpackConfig({ - resolve: { - alias: { - [path.resolve(__dirname, 'sidebar')]: path.resolve( - 'src', - 'gatsby-theme-iterative-docs', - 'sidebar' - ), - [path.resolve(__dirname, 'redirects')]: path.resolve( - 'src', - 'gatsby-theme-iterative-docs', - 'redirects' - ) - } - } - }) -} - -exports.createPages = require('./createPages.js') - -exports.onCreateNode = require('./onCreateNode.js') diff --git a/plugins/gatsby-theme-iterative-docs/index.js b/plugins/gatsby-theme-iterative-docs/index.js deleted file mode 100644 index 172f1ae6a4..0000000000 --- a/plugins/gatsby-theme-iterative-docs/index.js +++ /dev/null @@ -1 +0,0 @@ -// noop diff --git a/plugins/gatsby-theme-iterative-docs/onCreateNode.js b/plugins/gatsby-theme-iterative-docs/onCreateNode.js deleted file mode 100644 index 3a812e6e98..0000000000 --- a/plugins/gatsby-theme-iterative-docs/onCreateNode.js +++ /dev/null @@ -1,49 +0,0 @@ -const path = require('path') - -function onCreateNode( - { - node, - getNode, - createNodeId, - createContentDigest, - actions: { createNode, createParentChildLink } - }, - { disable } -) { - if (disable || node.internal.type !== 'MarkdownRemark') { - return - } - const parentNode = getNode(node.parent) - const splitDir = parentNode.relativeDirectory.split(path.sep) - if (splitDir[0] !== 'docs') return - - const { name, relativePath } = parentNode - splitDir[0] = 'doc' - - const slug = path.posix.join('/', ...splitDir, name === 'index' ? '' : name) - - const fieldData = { - slug, - rawMarkdownBody: node.rawMarkdownBody, - sourcePath: relativePath, - template: node.frontmatter.template, - title: node.frontmatter.title === '' ? null : node.frontmatter.title, - description: node.frontmatter.description - } - - const docNode = { - ...fieldData, - id: createNodeId(`MarkdownDocsPage >>> ${node.id}`), - parent: node.id, - children: [], - internal: { - type: `DocsPage`, - contentDigest: createContentDigest(fieldData) - } - } - - createNode(docNode) - createParentChildLink({ parent: node, child: docNode }) -} - -module.exports = onCreateNode diff --git a/plugins/gatsby-theme-iterative-docs/package.json b/plugins/gatsby-theme-iterative-docs/package.json deleted file mode 100644 index baa489d3ce..0000000000 --- a/plugins/gatsby-theme-iterative-docs/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "gatsby-theme-iterative-docs", - "version": "0.0.1", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "MIT" -} diff --git a/plugins/gatsby-theme-iterative-docs/pseudo-shadow.js b/plugins/gatsby-theme-iterative-docs/pseudo-shadow.js deleted file mode 100644 index ecb00e71f9..0000000000 --- a/plugins/gatsby-theme-iterative-docs/pseudo-shadow.js +++ /dev/null @@ -1,3 +0,0 @@ -const path = require('path') -const pseudoShadow = modulePath => require(path.resolve(modulePath)) -module.exports = pseudoShadow diff --git a/plugins/gatsby-theme-iterative-docs/redirects.js b/plugins/gatsby-theme-iterative-docs/redirects.js deleted file mode 100644 index 6a3c513609..0000000000 --- a/plugins/gatsby-theme-iterative-docs/redirects.js +++ /dev/null @@ -1,2 +0,0 @@ -const pseudoShadow = require('./pseudo-shadow') -module.exports = pseudoShadow('./src/gatsby-theme-iterative-docs/redirects') diff --git a/plugins/gatsby-theme-iterative-docs/sidebar.js b/plugins/gatsby-theme-iterative-docs/sidebar.js deleted file mode 100644 index 5d2bfd37b5..0000000000 --- a/plugins/gatsby-theme-iterative-docs/sidebar.js +++ /dev/null @@ -1,2 +0,0 @@ -const pseudoShadow = require('./pseudo-shadow') -module.exports = pseudoShadow('./src/gatsby-theme-iterative-docs/sidebar') diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SearchForm/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SearchForm/index.tsx deleted file mode 100644 index 38fe96a4e7..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SearchForm/index.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import React, { useEffect, useState } from 'react' -import Promise from 'promise-polyfill' -import { loadResource } from '../../../../utils/front/resources' - -import * as styles from './styles.module.css' - -declare global { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface Window { - docsearch?: (opts: Record) => void - } -} - -const SearchForm: React.FC = props => { - const [isLoaded, setLoaded] = useState(false) - - useEffect(() => { - Promise.all([ - loadResource( - 'https://cdn.jsdelivr.net/npm/docsearch.js@2.6.2/dist/cdn/docsearch.min.css' - ), - loadResource( - 'https://cdn.jsdelivr.net/npm/docsearch.js@2.6.2/dist/cdn/docsearch.min.js' - ) - ]).then(() => setLoaded(true)) - }, []) - - useEffect(() => { - if (isLoaded) { - window.docsearch && - window.docsearch({ - apiKey: '755929839e113a981f481601c4f52082', - indexName: 'dvc', - inputSelector: '#doc-search', - debug: false // Set to `true` if you want to inspect the dropdown - }) - } - }, [isLoaded]) - - if (!isLoaded) { - return null - } - - return ( -
-
- -
-
- ) -} - -export default SearchForm diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SearchForm/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SearchForm/styles.module.css deleted file mode 100644 index e8fed9823e..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SearchForm/styles.module.css +++ /dev/null @@ -1,46 +0,0 @@ -.searchArea { - box-sizing: border-box; - height: 60px; - padding-top: 10px; - z-index: 10; - position: sticky; - top: var(--layout-header-height); - - @media (--xs-scr) { - position: relative; - padding: 10px 20px 0; - top: 0; - } - - input { - height: 40px; - } - - :global(.algolia-autocomplete .ds-dropdown-menu) { - margin-top: -5px; - } -} - -.container { - width: 100%; - height: 100%; - display: flex; -} - -.input { - box-sizing: border-box; - display: flex; - flex: 1; - width: 240px; - height: 100%; - padding-left: 48px; - padding-right: 24px; - border: solid 1px var(--color-lighter-blue); - border-radius: 200px; - background-color: #fff; - background-image: url("/img/search.svg"); - background-repeat: no-repeat; - background-position: 15px center; - font-size: 16px; - font-weight: 500; -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/InnerSidebar/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/InnerSidebar/index.tsx deleted file mode 100644 index 3c2449cd9c..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/InnerSidebar/index.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react' -import includes from 'lodash/includes' -import * as styles from '../styles.module.css' -import { structure } from '../../../../../utils/shared/sidebar' -import SidebarMenuItem from '../Item' -import { SidebarItemClickHandler } from '..' - -export interface IInnerSidebarProps { - activePaths: string[] - onClick: SidebarItemClickHandler -} - -const SidebarSections: React.FC = ({ - activePaths, - onClick -}) => { - return ( -
-
- {structure.map(item => ( - - ))} -
-
- ) -} - -export default SidebarSections diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/Item/external-link-icon.svg b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/Item/external-link-icon.svg deleted file mode 100644 index a6c4bbd0db..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/Item/external-link-icon.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/Item/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/Item/index.tsx deleted file mode 100644 index b91cdec6af..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/Item/index.tsx +++ /dev/null @@ -1,143 +0,0 @@ -import React, { SyntheticEvent, useEffect, useState } from 'react' -import { Collapse } from 'react-collapse' -import cn from 'classnames' -import includes from 'lodash/includes' - -import Link from '../../../../Link' -import { ReactComponent as ExternalLinkIcon } from './external-link-icon.svg' -import * as styles from '../styles.module.css' - -import ICONS from '../icons' -import { getPathWithSource } from '../../../../../utils/shared/sidebar' - -interface ISidebarMenuItemProps { - children?: Array<{ label: string; path: string; source: boolean | string }> - label: string - path: string - source: boolean | string - onClick: (isLeafItemClicked: boolean) => void - activePaths?: Array - type?: string - style?: string - icon?: string -} - -const SidebarMenuItem: React.FC = ({ - children, - label, - path, - activePaths, - onClick, - style, - icon, - type -}) => { - const [isExpanded, setIsExpanded] = useState( - activePaths && includes(activePaths, path) - ) - - useEffect(() => { - setIsExpanded(activePaths && includes(activePaths, path)) - }, [activePaths]) - - const isRootParent = - activePaths && activePaths.length > 1 && activePaths[0] === path - - const isLeafItem = children === undefined || children.length === 0 - - const currentLevelOnClick = ( - event: SyntheticEvent - ): void => { - if (event.currentTarget.getAttribute('aria-current') === 'page') { - event.preventDefault() - setIsExpanded(!isExpanded) - } - onClick(isLeafItem) - } - - const bulletIconClick = (event: SyntheticEvent): void => { - event.preventDefault() - setIsExpanded(!isExpanded) - } - - // Fetch a special icon if one is defined - const IconComponent = icon && ICONS[icon] - const iconElement = IconComponent ? ( - - ) : null - - const className = cn( - styles.sectionLink, - isExpanded && styles.active, - isRootParent && 'docSearch-lvl0', - 'link-with-focus', - // style ? styles[style] : styles.sidebarDefault, - style && styles[style], - // isLeafItem && styles.leafItem, - // Limit the default bullet to items with no special icon - // icon ? undefined : styles.withDefaultBullet - icon && undefined - ) - - const bulletIconClassName = cn( - styles.sidebarDefaultBullet, - isExpanded && styles.active, - isLeafItem && styles.sidebarLeafBullet - ) - - const bulletIconJSX = isLeafItem ? ( - - ) : ( - - ) - - const parentElement = - type === 'external' ? ( - - {iconElement ? ( - iconElement - ) : ( - - )} - {label} - - ) : ( - - {iconElement ? iconElement : bulletIconJSX} - {label} - - ) - - return ( - <> - {parentElement} - {children && ( - - )} - - ) -} - -export default SidebarMenuItem diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/icons/house.svg b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/icons/house.svg deleted file mode 100644 index a24454c0d3..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/icons/house.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/icons/index.ts b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/icons/index.ts deleted file mode 100644 index c4bb218e89..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/icons/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ReactComponent as HouseIcon } from './house.svg' - -export type SidebarIcons = { [key: string]: React.FC<{ className?: string }> } - -const ICONS: SidebarIcons = { - house: HouseIcon -} - -export default ICONS diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/index.tsx deleted file mode 100644 index 8af0c57339..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/index.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import React, { useEffect, useRef, useState } from 'react' -import { useLocation } from '@reach/router' -import cn from 'classnames' -import PerfectScrollbar from 'perfect-scrollbar' - -import { getParentsListFromPath } from '../../../../utils/shared/sidebar' - -import 'perfect-scrollbar/css/perfect-scrollbar.css' -import * as styles from './styles.module.css' - -import InnerSidebar from './InnerSidebar' - -export type SidebarItemClickHandler = (isLeafItemClicked: boolean) => void - -interface ISidebarMenuProps { - currentPath: string - onClick: SidebarItemClickHandler -} - -const SidebarMenu: React.FC = ({ currentPath, onClick }) => { - const location = useLocation() - const rootRef = useRef(null) - const psRef = useRef(undefined) - const [isScrollHidden, setIsScrollHidden] = useState(false) - const activePaths = currentPath && getParentsListFromPath(currentPath) - - const scrollToActiveItem = (): void => { - const node = document.getElementById(currentPath) - const parent = rootRef.current - - setIsScrollHidden(true) - setTimeout(() => { - if (node && parent) { - psRef.current?.update() - - const parentHeight = parent.clientHeight - const parentScroll = parent.scrollTop - const nodeOffset = node.offsetTop - const nodeHeight = node.clientHeight - const scrollOffset = nodeOffset - parentHeight + nodeHeight - - if ( - parentScroll > nodeOffset + nodeHeight || - parentScroll + parentHeight < nodeOffset - ) { - parent.scrollTop = scrollOffset - } - } - - setIsScrollHidden(false) - }, 400) - } - - useEffect(() => { - if (!psRef.current && rootRef.current) { - psRef.current = new PerfectScrollbar(rootRef.current, { - wheelPropagation: true - }) - } - - scrollToActiveItem() - - return (): void => { - psRef.current?.destroy() - psRef.current = undefined - } - }, []) - useEffect(scrollToActiveItem, [location.pathname]) - - return ( -
- -
- ) -} - -export default SidebarMenu diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/styles.module.css deleted file mode 100644 index 12a862b24b..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/SidebarMenu/styles.module.css +++ /dev/null @@ -1,118 +0,0 @@ -.menu { - position: sticky; - top: calc(var(--layout-header-height) + 60px); - height: calc(100vh - var(--layout-header-height) - 60px); - overflow-y: hidden; - -webkit-overflow-scrolling: touch; - - &.isScrollHidden { - .ps__rail-y { - opacity: 0; - overflow: hidden; - } - } - - @media (--xs-scr) { - position: relative; - top: 0; - height: calc(100% - 60px); - padding-left: 20px; - } - - :global(.ReactCollapse--collapse) { - transition: height 500ms; - padding-left: 10px; - } -} - -.sections { - min-width: 280px; - margin-bottom: 25px; - margin-top: 10px; - - @media (--xs-scr) { - min-width: auto; - } -} - -.sectionLinks { - @media (--sm-scr) { - position: relative; - } -} - -.sectionLink { - display: block; - position: relative; - min-height: 26px; - margin: 0; - padding: 0 0 5px 15px; - font-size: 18px; - line-height: 26px; - font-weight: 400; - text-decoration: none; - color: var(--color-gray-light); - - &:hover { - color: #3c3937; - - @media (--xs-scr) { - color: var(--color-gray-light); - } - } - - &.active { - color: var(--color-gray-hover); - - .sidebarDefaultBullet { - animation: rotateIcon 0.5s forwards; - } - } -} - -@keyframes rotateIcon { - 100% { - transform: rotate(90deg); - } -} - -.footer { - margin-top: 30px; - padding-bottom: 30px; -} - -.specialIcon { - color: var(--color-gray-light); - position: absolute; - width: 0.65rem; - height: 0.65rem; - top: 0.5rem; - left: -0.08rem; -} - -.sidebarDefaultBullet { - content: ""; - position: absolute; - left: 0; - top: 9px; - display: block; - border: none; - height: 8px; - width: 8px; - background: url("/img/triangle_dark.svg") no-repeat center center; - transition: 0.5s transform; - - &:focus { - outline-color: var(--color-gray-light); - outline-offset: 0; - } - - &:hover { - transform: scale(1.5); - } - - &.sidebarLeafBullet { - background: url("/img/default_bullet_dark.svg") no-repeat center center; - transform: unset; - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/index.tsx deleted file mode 100644 index fc9526627a..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/index.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import React, { Reducer, useEffect, useReducer } from 'react' -import cn from 'classnames' - -import LayoutWidthContainer from '../../LayoutWidthContainer' -import HamburgerIcon from '../../HamburgerIcon' -import SearchForm from './SearchForm' -import SidebarMenu from './SidebarMenu' -import { matchMedia } from '../../../utils/front/breakpoints' -import { focusElementWithHotkey } from '../../../utils/front/focusElementWithHotkey' - -import * as styles from './styles.module.css' -import { useWindowSize } from 'react-use' - -const toggleReducer: Reducer = state => !state - -const Layout: React.FC<{ currentPath: string }> = ({ - children, - currentPath -}) => { - const [isMenuOpen, toggleMenu] = useReducer(toggleReducer, false) - - const windowSize = useWindowSize() - - useEffect(() => { - if (matchMedia('--xs-scr')) { - return - } - const closeEventListener = focusElementWithHotkey('#doc-search', '/') - return closeEventListener - }, [windowSize]) - - return ( - - {/* eslint-disable jsx-a11y/no-static-element-interactions */} - {/* eslint-disable jsx-a11y/click-events-have-key-events */} -
- {/* eslint-enable jsx-a11y/no-static-element-interactions */} - {/* eslint-enable jsx-a11y/click-events-have-key-events */} - - - -
- - { - if (matchMedia('--xs-scr') && isLeafItemClicked) { - toggleMenu() - } - }} - /> -
-
{children}
- - ) -} - -export default Layout diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/styles.module.css deleted file mode 100644 index 97a1187c72..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Layout/styles.module.css +++ /dev/null @@ -1,113 +0,0 @@ -.container { - display: flex; - flex-direction: row; - z-index: 2; - - @media (--xs-scr) { - padding: 0 15px; - } - - &::before { - content: ""; - display: block; - position: fixed; - z-index: -1; - top: 0; - left: 0; - bottom: 0; - width: 50%; - pointer-events: none; - background-color: var(--color-light-blue); - - @media (--xs-scr) { - display: none; - } - } -} - -.backdrop { - display: none; - - @media (--xs-scr) { - display: block; - opacity: 0; - pointer-events: none; - transition: opacity 0.3s linear; - - &.opened { - content: ""; - position: fixed; - top: 0; - left: 0; - bottom: 0; - right: 0; - z-index: 1; - opacity: 1; - pointer-events: all; - background-color: rgb(0 0 0 / 40%); - } - } -} - -.side { - flex-shrink: 0; - width: 280px; - background-color: var(--color-light-blue); - - @media (--xs-scr) { - position: fixed; - display: block; - z-index: 2; - top: var(--layout-header-height); - bottom: 0; - left: 0; - right: 60px; - box-shadow: rgb(0 0 0 / 14%) 0 0 4px, rgb(0 0 0 / 28%) 0 4px 8px; - transform: translateX(-110%); - transition: transform 0.35s ease; - - &.opened { - transform: translateX(0); - } - } -} - -.sideToggle { - display: none; - justify-content: center; - align-items: center; - position: fixed; - z-index: 2; - left: 8px; - bottom: 20px; - width: 45px; - height: 45px; - border: none; - border-radius: 50%; - background-color: rgb(255 255 255 / 90%); - box-shadow: 0 0 9px 0 rgb(0 0 0 / 15%); - transition: transform 0.3s ease; - - &.opened { - transform: translateX(calc(100vw - 60px)); - } - - @media (--xs-scr) { - display: flex; - - > * { - transform: scale(0.75); - } - } -} - -.content { - display: flex; - flex-direction: row; - max-width: calc(100% - 280px); - background-color: #fff; - - @media (--xs-scr) { - max-width: 100%; - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Main/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Main/index.tsx deleted file mode 100644 index e51111aa42..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Main/index.tsx +++ /dev/null @@ -1,111 +0,0 @@ -import React, { useEffect, useRef, useCallback } from 'react' -import cn from 'classnames' -import { navigate } from '@reach/router' - -import Link from '../../../Link' -import Tutorials from '../../TutorialsLinks' -import { getPathWithSource } from '../../../../utils/shared/sidebar' -import useCustomYtEmbeds from '../../../../utils/front/useCustomYtEmbeds' - -import 'github-markdown-css/github-markdown-light.css' -import * as sharedStyles from '../../styles.module.css' -import * as styles from './styles.module.css' - -const isInsideCodeBlock = (node: Element): boolean => { - while (node?.parentNode) { - if (node.tagName === 'PRE') { - return true - } - - if (node.tagName === 'ARTICLE') { - return false - } - - node = node.parentNode as Element - } - - return false -} - -interface IMainProps { - githubLink: string - tutorials: { [type: string]: string } - prev?: string - next?: string -} - -const Main: React.FC = ({ - children, - prev, - next, - tutorials, - githubLink -}) => { - const touchstartXRef = useRef(0) - const touchendXRef = useRef(0) - const isCodeBlockRef = useRef(false) - useCustomYtEmbeds() - const handleSwipeGesture = useCallback(() => { - if (isCodeBlockRef.current) return - - if (next && touchstartXRef.current - touchendXRef.current > 100) { - navigate(next) - } - - if (prev && touchendXRef.current - touchstartXRef.current > 100) { - navigate(prev) - } - }, [prev, next]) - const onTouchStart = useCallback(e => { - isCodeBlockRef.current = isInsideCodeBlock(e.target) - touchstartXRef.current = e.changedTouches[0].screenX - }, []) - const onTouchEnd = useCallback(e => { - touchendXRef.current = e.changedTouches[0].screenX - handleSwipeGesture() - }, []) - - useEffect(() => { - document.addEventListener('touchstart', onTouchStart, false) - document.addEventListener('touchend', onTouchEnd, false) - - return (): void => { - document.removeEventListener('touchstart', onTouchStart) - document.removeEventListener('touchend', onTouchEnd) - } - }, []) - - return ( -
- {tutorials && ( -
- -
- )} - - Edit on - GitHub - -
{children}
-
- - - Prev - - - Next - - -
-
- ) -} - -export default Main diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Main/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Main/styles.module.css deleted file mode 100644 index d4324c4701..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Main/styles.module.css +++ /dev/null @@ -1,432 +0,0 @@ -:global { - ul { - list-style-type: disc; - } - - ol { - list-style-type: decimal; - } - - em { - font-style: italic; - } - - #markdown-root { - @keyframes fadeIn { - from { - opacity: 0; - } - - to { - opacity: 1; - } - } - - animation-duration: 1s; - animation-fill-mode: both; - - :local { - animation-name: fadeIn; - } - } - - .markdown-body { - font-family: inherit; - font-size: 18px; - - h1, - h2, - h3, - h4, - h5, - h6 { - font-weight: 500; - } - - img + em, - :global(.gatsby-resp-image-wrapper) + em { - color: #6a737d; - font-size: 0.9em; - display: block; - margin-top: -6px; - text-align: center; - } - - :global(.gatsby-resp-image-wrapper) + em { - margin-top: 0; - } - - a[target="_blank"] { - white-space: nowrap; - - &::after { - position: relative; - top: 1px; - right: 0; - width: 12px; - height: 12px; - margin-left: 1px; - content: url("/img/external-link.svg"); - } - } - - a.token.arg { - color: var(--color-light-blue); - outline-color: var(--color-light-blue-hover); - } - - :global(a.gatsby-resp-image-link)::after { - content: unset; - } - - li .anchor svg { - visibility: hidden; - } - - li:hover .anchor svg { - visibility: visible; - } - - li .anchor:focus svg { - visibility: visible; - } - - li .anchor { - line-height: unset; - } - - .anchor { - margin-left: -24px; - } - - li { - margin: 16px 0; - } - - pre[class*="language-"] { - background: #40354d; - color: #ccc; - - .token.line { - color: #ddd; - } - - .token.comment, - .token.block-comment { - font-weight: normal; - color: #a0a0a0; - } - - .token.input { - user-select: none; - } - - .token.prolog, - .token.doctype, - .token.cdata { - color: #999; - } - - .token.url, - .token.constant, - .token.operator, - .token.punctuation { - color: #a0a0a0; - } - - .token.property, - .token.tag, - .token.boolean, - .token.function-name, - .token.symbol, - .token.deleted { - color: #4badd2; - } - - .token.function { - color: #ae41bb; - } - - .token.number, - .token.attr-name, - .token.string, - .token.char, - .token.builtin, - .token.inserted { - color: #219161; - } - - .token.entity, - .token.variable { - color: #a67f59; - } - - .token.class-name { - color: #0086b3; - } - - .token.dvc { - color: #56b1d0; - font-weight: bold; - } - - .token.usage, - .token.git { - color: #e9836e; - } - - .token.command, - .token.selector, - .token.atrule, - .token.attr-value, - .token.keyword { - color: #e4b872; - } - - .token.regex, - .token.important { - color: #b68; - } - - .token.parameter { - color: #a0a0a0; - } - - .token.function-variable { - color: #7ece42; - } - - .token.important { - font-weight: normal; - } - - .token.bold { - font-weight: bold; - } - - .token.italic { - font-style: italic; - } - - .token.entity { - cursor: help; - } - - .token.namespace { - opacity: 0.7; - } - - .token.hide { - display: none; - } - - .token.bg-white { - color: #000; - background-color: #eee; - } - - .token.bg-yellow { - color: #000; - background-color: #fffed7; - } - - .token.bg-blue { - color: #000; - background-color: #d7feff; - } - - .token.bg-violet { - color: #000; - background-color: #d7afff; - } - } - - pre[class*="language-dvctable"] { - code { - display: inline-block; - line-height: 20px; - } - - .token.rows { - background-image: linear-gradient( - transparent 50%, - rgb(256 256 256 / 10%) 50% - ); - background-size: 100% 40px; - display: block; - background-origin: content-box; - background-attachment: local; - } - } - } - - details p { - font-size: 17px; - color: var(--color-gray-dark); - margin-left: 20px; - margin-right: 10px; - } - - details pre { - font-size: 14px; - color: var(--color-gray-dark); - margin-left: 20px; - margin-right: 10px; - } - - .yt-embed-wrapper { - position: relative; - display: flex; - margin-top: 0; - margin-bottom: 16px; - - &:hover &__tooltip { - opacity: 1; - } - - &__overlay { - position: absolute; - bottom: 0; - left: 0; - width: 100%; - height: 100%; - display: flex; - align-items: flex-end; - - &:hover { - cursor: pointer; - } - - &.hidden { - display: none; - } - } - - &__tooltip { - padding: 10px; - box-sizing: border-box; - color: #fff; - opacity: 0; - width: 100%; - font-size: 16px; - background-color: rgb(23 23 23 / 59%); - text-shadow: 0 1px 0 rgb(33 45 69 / 25%); - transition: opacity 0.2s ease-in-out; - - &:hover { - cursor: auto; - } - - a { - @mixin focus; - - color: #fff; - text-decoration: underline; - - &::after { - display: none; - } - } - } - } -} - -.content { - min-width: 200px; - margin: 30px; - flex: 1; - background-color: #fff; - - @media (--xs-scr) { - margin: 15px 0; - } -} - -.tutorialsWrapper { - position: relative; - z-index: 1; - float: right; - margin: 5px 0 0 10px; - - @media (--md-scr) { - margin: 0 0 15px; - } - - @media only screen and (min-width: 1200px) { - display: none; - } -} - -.githubLink { - display: none; - float: right; - margin: 5px 0 10px 10px; - z-index: 1; - position: relative; - - @media (--md-scr) { - float: none; - margin: 0 0 15px; - } - - @media only screen and (max-width: 1200px) { - display: inline-flex; - } -} - -.githubIcon { - background-image: url("/img/github_icon.svg"); -} - -.navButtons { - display: flex; - justify-content: space-between; - align-items: center; - margin-top: 40px; - font-size: 14px; - font-weight: 600; -} - -.navButton { - text-decoration: none; - background: white; - padding: 10px 15px; - text-transform: uppercase; - color: #333; - border-bottom: 3px solid #13adc7; - display: inline-flex; - align-items: center; - transition: 0.2s border-color ease-out; - - &:hover { - border-bottom: 3px solid #11849b; - } - - &[disabled] { - pointer-events: none; - opacity: 0.5; - } -} - -.navButtonIcon { - display: inline-block; - width: 1em; - height: 1em; - line-height: 1; - background-image: url("/img/arrow.svg"); - background-size: contain; - background-position: center; - background-repeat: no-repeat; - transition: all 0.3s; - - &.next { - margin-left: 7px; - } - - &.prev { - margin-right: 7px; - mask-position: center; - transform: rotate(180deg); - margin-top: 2px; - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/ToggleProvider/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/ToggleProvider/index.tsx deleted file mode 100644 index be44e88c22..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/ToggleProvider/index.tsx +++ /dev/null @@ -1,109 +0,0 @@ -import React, { createContext, useEffect, useState } from 'react' - -interface ITogglesData { - [key: string]: { - texts: string[] - checkedInd: number - parentText: string | null - } -} - -interface ITogglesContext { - addNewToggle?: ( - id: string, - texts: string[], - parentText: string | null - ) => void - updateToggleInd?: (id: string, newInd: number) => void - togglesData?: ITogglesData -} - -export const TogglesContext = createContext({}) - -const makeTextUrlFriendly = (val: string): string => - val.replace(/[^\w\-\._~]/g, '-').replace(/-+/g, '-') - -const convertTabTextToQueryText = ( - text: string, - parentText: string | null -): string => makeTextUrlFriendly(`${parentText ? `${parentText} ` : ''}${text}`) - -const getUrlQueryVal = (query: string, param: string): string => { - const params = new URLSearchParams(query) - return params.get(param) || '' -} - -const setUrlQuery = (href: string, param: string, value: string): void => { - const formattedVal = makeTextUrlFriendly(value) - const url = new URL(href) - url.searchParams.set(param, formattedVal) - window.history.pushState({}, '', url.href) -} - -const getSelectedIndexBasedOffQueryVal = ( - texts: string[], - queryVal: string, - parentText: string | null -): number => { - const urlFriendlyTexts = texts.map(text => - convertTabTextToQueryText(text, parentText) - ) - const index = urlFriendlyTexts.findIndex(text => queryVal.startsWith(text)) - return index > -1 ? index : 0 -} - -export const TogglesProvider: React.FC = ({ children }) => { - const [togglesData, setTogglesData] = useState({}) - const [lastSelectedTab, setLastSelectedTab] = useState(null) - - useEffect(() => { - const tab = getUrlQueryVal(window.location.search, 'tab') - setLastSelectedTab(tab) - }, []) - - const addNewToggle = ( - id: string, - texts: string[], - parentText: string | null - ): void => { - let lastSelected = lastSelectedTab - const togglesDataCopy: ITogglesData = { ...togglesData } - - if (lastSelected === null) { - lastSelected = getUrlQueryVal(window.location.search, 'tab') - } - - togglesDataCopy[id] = { - texts, - checkedInd: getSelectedIndexBasedOffQueryVal( - texts, - lastSelected, - parentText - ), - parentText - } - setTogglesData(togglesDataCopy) - } - - const updateToggleInd = (id: string, newInd: number): void => { - const togglesDataCopy: ITogglesData = { ...togglesData } - const selectedTabText = togglesDataCopy[id].texts[newInd] - togglesDataCopy[id] = { ...togglesDataCopy[id], checkedInd: newInd } - - setUrlQuery( - window.location.href, - 'tab', - convertTabTextToQueryText(selectedTabText, togglesDataCopy[id].parentText) - ) - setLastSelectedTab(selectedTabText) - setTogglesData(togglesDataCopy) - } - - return ( - - {children} - - ) -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/DesktopView/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/DesktopView/index.tsx deleted file mode 100644 index 3a69b1bad1..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/DesktopView/index.tsx +++ /dev/null @@ -1,133 +0,0 @@ -import React, { useRef, useState, useEffect } from 'react' -import cn from 'classnames' -import Portal from '@reach/portal' -import throttle from 'lodash/throttle' - -import { getHeaderHeight } from '../../../../../utils/front/scroll' -import * as styles from './styles.module.css' - -interface IDesktopViewProps { - description: string - header: string - text: React.ReactNode -} - -interface ITooltipPosition { - left: number - top: number - arrow: ['l' | 'r', 't' | 'b'] -} - -const ARROW_SIZE = 10 - -const getPosition = (toggle: Element, tooltip: Element): ITooltipPosition => { - const toggleRect = toggle.getBoundingClientRect() - const tooltipRect = tooltip.getBoundingClientRect() - const windowWidth = document.documentElement.clientWidth - const headerHeight = getHeaderHeight() - const result: ITooltipPosition = { left: 0, top: 0, arrow: ['l', 'b'] } - - if (windowWidth - tooltipRect.width > toggleRect.left) { - result.left = toggleRect.left - } else { - result.left = toggleRect.left + toggleRect.width - tooltipRect.width - result.arrow[0] = 'r' - } - - if (toggleRect.top > tooltipRect.height + ARROW_SIZE + headerHeight) { - result.top = toggleRect.top - tooltipRect.height - ARROW_SIZE - } else { - result.top = toggleRect.top + toggleRect.height + ARROW_SIZE - result.arrow[1] = 't' - } - - return result -} - -const DesktopView: React.FC = ({ - description, - header, - text -}) => { - const timeoutRef = useRef() - const toggleRef = useRef(null) - const tooltipRef = useRef(null) - const [tooltipPosition, setPosition] = useState< - ITooltipPosition | undefined - >() - const [isVisible, setVisible] = useState(false) - const calcPosition = (): void => { - if (!tooltipRef.current || !toggleRef.current) { - return - } - - setPosition(getPosition(toggleRef.current, tooltipRef.current)) - } - const throttledCalcPosition = throttle(calcPosition, 50) - const show = (): void => { - if (timeoutRef.current) { - clearTimeout(timeoutRef.current) - timeoutRef.current = undefined - } - - setVisible(true) - } - const hide = (): void => { - timeoutRef.current = window.setTimeout(() => setVisible(false), 100) - } - - useEffect(() => { - document.addEventListener('scroll', throttledCalcPosition) - window.addEventListener('resize', throttledCalcPosition) - - return (): void => { - document.removeEventListener('scroll', throttledCalcPosition) - window.removeEventListener('resize', throttledCalcPosition) - } - }, []) - useEffect(() => { - if (isVisible) { - requestAnimationFrame(calcPosition) - } - }, [isVisible]) - - return ( - <> - {isVisible && ( - -
-
{header}
-
-
- - )} - - {text} - - - ) -} - -export default DesktopView diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/DesktopView/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/DesktopView/styles.module.css deleted file mode 100644 index 86cce0c84d..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/DesktopView/styles.module.css +++ /dev/null @@ -1,78 +0,0 @@ -.highlightedText { - border-bottom: 1px black dotted; - white-space: nowrap; -} - -.tooltip { - box-sizing: border-box; - position: fixed; - top: 0; - left: 0; - display: block; - opacity: 0; - width: 400px; - padding: 10px 10px 16px; - border: 1px solid var(--color-lighter-blue); - border-radius: 3px; - font-family: var(--font-brandon); - color: var(--color-black); - background-color: #fff; - box-shadow: 0 1px 3px rgb(0 0 0 / 10%); - - &.calculated { - opacity: 1; - } - - &::after { - position: absolute; - content: ""; - display: block; - height: 12px; - width: 12px; - border: none; - border-top: 1px solid var(--color-lighter-blue); - border-left: 2px solid var(--color-lighter-blue); - transform: rotate(90deg); - background-color: #fff; - } - - &.lt::after, - &.rt::after { - top: -8px; - border-top-width: 2px; - border-left-width: 1px; - transform: rotate(45deg); - } - - &.lt::after { - left: 27px; - } - - &.rt::after { - right: 27px; - } - - &.lb::after, - &.rb::after { - top: 100%; - margin-top: -5px; - transform: rotate(-135deg); - } - - &.lb::after { - left: 27px; - } - - &.rb::after { - right: 27px; - } -} - -.tooltipHeader { - font-size: 1.5em; - font-weight: bold; -} - -.tooltipBody { - font-size: 1.1em; -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/MobileView/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/MobileView/index.tsx deleted file mode 100644 index 7c58dc58d4..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/MobileView/index.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import React, { useState } from 'react' -import cn from 'classnames' -import Portal from '@reach/portal' - -import { isTriggeredFromKB } from '../../../../../utils/front/keyboard' - -import * as styles from './styles.module.css' - -interface IMobileViewProps { - description: string - header: string - text: React.ReactNode -} - -const MobileView: React.FC = ({ - description, - header, - text -}) => { - const [isVisible, setVisible] = useState(false) - const openTooltip = (e: React.MouseEvent): void => { - e.stopPropagation() - setVisible(true) - } - const onOpenKeyDown = (e: React.KeyboardEvent): void => { - if (isTriggeredFromKB(e)) { - setVisible(true) - } - } - const closeTooltip = (e: React.MouseEvent): void => { - e.stopPropagation() - setVisible(false) - } - const onCloseKeyDown = (e: React.KeyboardEvent): void => { - if (isTriggeredFromKB(e)) { - setVisible(false) - } - } - - return ( - <> - - {text} - - {isVisible && ( - - {/* eslint-disable jsx-a11y/no-static-element-interactions*/} - {/* eslint-disable jsx-a11y/click-events-have-key-events */} -
- {/* eslint-enable jsx-a11y/no-static-element-interactions*/} - {/* eslint-enable jsx-a11y/click-events-have-key-events */} -
-
-
-
-
-
{header}
-
-
-
- - )} - - ) -} - -export default MobileView diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/MobileView/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/MobileView/styles.module.css deleted file mode 100644 index 7beee71adb..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/MobileView/styles.module.css +++ /dev/null @@ -1,49 +0,0 @@ -.highlightedText { - border-bottom: 1px black dotted; -} - -.modalBackground { - position: fixed; - z-index: 100; - top: 0; - left: 0; - height: 100vh; - width: 100%; - display: flex; - align-items: center; - justify-content: center; - background-color: rgb(0 0 0 / 40%); -} - -.closeContainer { - float: right; - margin: 2px 10px 0 0; -} - -.closeLine { - position: absolute; - height: 23px; - width: 2px; - background-color: black; - - &.first { - transform: rotate(-45deg); - } - - &.second { - transform: rotate(45deg); - } -} - -.modalContent { - width: 80%; - padding: 8px 10px; - border: 1px solid var(--color-light-blue); - border-radius: 3px; - background-color: #fff; -} - -.modalHeader { - font-size: 1.3em; - font-weight: bold; -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/index.tsx deleted file mode 100644 index 4341b7a526..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/Tooltip/index.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import React, { useState, useEffect } from 'react' -import includes from 'lodash/includes' - -import ShowOnly from '../../../ShowOnly' -import DesktopView from './DesktopView' -import MobileView from './MobileView' - -import useGlossary from '../../../../utils/front/glossary' - -const Tooltip: React.FC<{ text: string }> = ({ text }) => { - const glossary = useGlossary() - const [state, setState] = useState({ - description: '', - header: '', - match: false - }) - - useEffect(() => { - glossary.contents.forEach(glossaryItem => { - if ( - includes( - glossaryItem.match.map(word => word.toLowerCase()), - text.replace(/\n/g, ' ').toLowerCase() - ) - ) { - setState({ - description: glossaryItem.desc, - header: glossaryItem.name, - match: true - }) - } - }) - }, [text]) - - if (!state.match) { - return {text} - } - - return ( - <> - - - - - - - - ) -} - -export default Tooltip diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/index.tsx deleted file mode 100644 index 650ae47a0b..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/index.tsx +++ /dev/null @@ -1,237 +0,0 @@ -import React, { - useEffect, - useState, - useRef, - ReactNode, - ReactElement, - useContext -} from 'react' -import cn from 'classnames' -import { nanoid } from 'nanoid' -import { Node } from 'unist' -import rehypeReact from 'rehype-react' -import Collapsible from 'react-collapsible' - -import Main from './Main' -import Link from '../../Link' -import Tooltip from './Tooltip' - -import * as styles from './styles.module.css' -import { TogglesContext, TogglesProvider } from './ToggleProvider' - -const Details: React.FC> = ({ children }) => { - const filteredChildren: ReactNode[] = ( - children as Array<{ props: { children: ReactNode } } | string> - ).filter(child => child !== '\n') - const firstChild = filteredChildren[0] as JSX.Element - - if (!/^h.$/.test(firstChild.type)) { - throw new Error('The first child of a details element must be a heading!') - } - - /* - To work around auto-linked headings, the last child of the heading node - must be removed. The only way around this is the change the autolinker, - which we currently have as an external package. - */ - const triggerChildren: ReactNode[] = firstChild.props.children.slice( - 0, - firstChild.props.children.length - 1 - ) as ReactNode[] - - /* - Collapsible's trigger type wants ReactElement, so we force a TS cast from - ReactNode here. - */ - return ( - - {filteredChildren.slice(1)} - - ) -} - -const Abbr: React.FC> = ({ children }) => { - return -} - -const Cards: React.FC = ({ children }) => { - return
{children}
-} - -const InnerCard: React.FC<{ - href?: string - className?: string -}> = ({ href, children, className }) => - href ? ( - - {children} - - ) : ( -
{children}
- ) - -const Card: React.FC<{ - icon?: string - heading?: string - href?: string - headingtag: - | string - | React.FC<{ - className: string - }> -}> = ({ children, icon, heading, headingtag: Heading = 'h3', href }) => { - let iconElement - - if (Array.isArray(children) && icon) { - const firstRealItemIndex = children.findIndex(x => x !== '\n') - iconElement = children[firstRealItemIndex] - children = children.slice(firstRealItemIndex + 1) - } - - return ( -
- - {iconElement &&
{iconElement}
} -
- {heading && ( - {heading} - )} - {children} -
-
-
- ) -} - -const ToggleTab: React.FC<{ - id: string - title: string - ind: number - onChange: () => void - checked: boolean -}> = ({ children, id, checked, ind, onChange, title }) => { - const inputId = `tab-${id}-${ind}` - - return ( - <> - - - {children} - - ) -} - -const Toggle: React.FC<{ - height?: string - children: Array<{ props: { title: string } } | string> -}> = ({ height, children }) => { - const [toggleId, setToggleId] = useState('') - const { - addNewToggle = (): null => null, - updateToggleInd = (): null => null, - togglesData = {} - } = useContext(TogglesContext) - const tabs: Array<{ props: { title: string } } | string> = children.filter( - child => child !== '\n' - ) - const tabsTitles = tabs.map(tab => - typeof tab === 'object' ? tab.props.title : '' - ) - const toggleEl = useRef(null) - - useEffect(() => { - const tabParent = - toggleEl.current && toggleEl.current.closest('.toggle .tab') - const labelParentText = - tabParent && - tabParent.previousElementSibling && - tabParent.previousElementSibling.textContent - - if (toggleId === '') { - const newId = nanoid() - addNewToggle(newId, tabsTitles, labelParentText) - setToggleId(newId) - } - - if (toggleId && !togglesData[toggleId]) { - addNewToggle(toggleId, tabsTitles, labelParentText) - } - }, [togglesData]) - - return ( -
- {tabs.map((tab, i) => ( - updateToggleInd(toggleId, i)} - > -
- {tab} -
-
- ))} -
- ) -} - -// Rehype's typedefs don't allow for custom components, even though they work -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const renderAst = new (rehypeReact as any)({ - createElement: React.createElement, - Fragment: React.Fragment, - components: { - a: Link, - abbr: Abbr, - card: Card, - cards: Cards, - details: Details, - toggle: Toggle, - tab: React.Fragment - } -}).Compiler - -interface IMarkdownProps { - htmlAst: Node - githubLink: string - tutorials: { [type: string]: string } - prev?: string - next?: string -} - -const Markdown: React.FC = ({ - htmlAst, - prev, - next, - tutorials, - githubLink -}) => { - return ( -
- {renderAst(htmlAst)} -
- ) -} - -export default Markdown diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/styles.module.css deleted file mode 100644 index 496bc1c82f..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/Markdown/styles.module.css +++ /dev/null @@ -1,173 +0,0 @@ -:global { - .Collapsible { - margin-bottom: 10px; - background-color: rgb(36 173 197 / 20%); - border-radius: 15px; - padding: 10px; - } - - .Collapsible__trigger { - font-family: var(--font-brandon); - font-weight: 500; - display: block; - position: relative; - opacity: 0.9; - cursor: pointer; - - &::after { - position: absolute; - display: inline-block; - background-size: 20px 20px; - right: 0; - width: 20px; - height: 20px; - background-image: url("/img/click.png"); - content: ""; - font-family: monospace; - transition: transform 200ms; - } - - &.is-open::after { - opacity: 0.5; - } - } - - .Collapsible__contentInner { - background-color: rgb(36 173 197 / 0%); - border-radius: 15px; - padding: 10px; - } -} - -.cards { - display: flex; - flex-flow: column nowrap; - margin: 1rem -0.5rem; - - @media screen and (min-width: 1024px) { - margin: 2rem -0.5rem; - flex-flow: row wrap; - - .cardWrapper { - flex: 1 0 50%; - min-height: 7rem; - } - - .card { - height: 100%; - } - } -} - -.cardWrapper { - margin: 0.5rem 0; - display: flex; -} - -.card { - flex: 1 0; - border: 1px solid #d6d6d6; - margin: 0 0.5rem; - border-radius: 10px; - padding: 0.75rem 1rem; - display: flex; - width: 100%; - height: 100%; - flex-flow: row nowrap; - align-items: center; - box-sizing: border-box; - - p { - margin: 0; - } - - .cardIcon { - box-sizing: border-box; - display: block; - padding: 0; - padding-right: 0.75rem; - flex: 0 0 75px; - - * { - margin: 0; - padding: 0; - display: block; - } - } - - .cardHeading { - margin: 0; - margin-bottom: 0.25em; - font-weight: bold; - color: var(--color-gray-dark); - } - - .cardContent { - flex: 1; - } -} - -a.card { - color: inherit; - text-decoration: inherit; - transition: background-color 0.3s ease-in-out; - background-color: #fff; - - &:hover { - text-decoration: inherit; - background-color: var(--color-light-blue); - } -} - -.toggle { - display: flex; - flex-wrap: wrap; - margin: 0 0 16px; - - input { - height: 0; - opacity: 0; - position: absolute; - width: 0; - overflow: hidden; - } - - input:checked + label { - color: var(--color-azure); - border-color: var(--color-azure); - } - - input:checked + label + .tab { - height: initial; - opacity: initial; - position: static; - width: 100%; - overflow: visible; - } - - .tabHeading { - padding: 12px 16px 10px; - background-color: transparent; - border: none; - border-bottom: 2px solid transparent; - font-weight: bold; - font-size: 16px; - font-family: var(--font-brandon); - order: -1; - - &:hover { - cursor: pointer; - } - } -} - -.tab { - margin: 0; - padding: 10px 10px 10px 20px; - background-color: rgb(27 31 35 / 5%); - height: 0; - opacity: 0; - position: absolute; - overflow: hidden; - width: 0; -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/RightPanel/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/RightPanel/index.tsx deleted file mode 100644 index ff7569d184..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/RightPanel/index.tsx +++ /dev/null @@ -1,219 +0,0 @@ -import React, { useState, useEffect, useRef } from 'react' -import cn from 'classnames' -import throttle from 'lodash/throttle' - -import { IHeading } from '../' -import Link from '../../Link' -import Tutorials from '../TutorialsLinks' - -import { getScrollPosition, getHeaderHeight } from '../../../utils/front/scroll' -import { allImagesLoadedInContainer } from '../../../utils/front/images' - -import * as sharedStyles from '../styles.module.css' -import * as styles from './styles.module.css' - -interface IRightPanelProps { - headings: Array - tutorials: { [type: string]: string } - githubLink: string -} - -interface IHeadingsCoordinates { - [offset: string]: string -} - -const RightPanel: React.FC = ({ - headings, - tutorials, - githubLink -}) => { - const [documentHeight, setDocumentHeight] = useState(0) - const [headingsOffsets, setHeadingsOffsets] = useState( - {} - ) - const [currentHeadingSlug, setCurrentHeadingSlug] = useState( - null - ) - const updateCurrentHeader = (): void => { - const currentScroll = getScrollPosition() - const coordinateKeys = Object.keys(headingsOffsets) - - if (!coordinateKeys.length) return - - const headerHeight = getHeaderHeight() - const filteredKeys = coordinateKeys.filter( - offsetTop => - parseInt(offsetTop, 10) <= - currentScroll + (documentHeight - headerHeight) / 2 - ) - - const newCurrentHeadingSlug = filteredKeys.length - ? headingsOffsets[filteredKeys[filteredKeys.length - 1]] - : null - - setCurrentHeadingSlug(newCurrentHeadingSlug) - } - - const updateHeadingsPosition = (): void => { - const offsets = headings.reduce( - (result: IHeadingsCoordinates, heading: IHeading) => { - const headingElement = document.getElementById(heading.slug) - - if (headingElement?.offsetTop) { - result[headingElement.offsetTop.toString()] = heading.slug - } - - return result - }, - {} - ) - setHeadingsOffsets(offsets) - setDocumentHeight(document.documentElement.clientHeight) - } - - const initHeadingsPosition = (): void => { - const root = document.querySelector('#markdown-root') - - root && allImagesLoadedInContainer(root).then(updateHeadingsPosition) - } - - useEffect(() => { - const throttledSetCurrentHeader = throttle(updateCurrentHeader, 100) - - document.addEventListener('scroll', throttledSetCurrentHeader) - window.addEventListener('resize', updateHeadingsPosition) - - return (): void => { - document.removeEventListener('scroll', throttledSetCurrentHeader) - window.removeEventListener('resize', updateHeadingsPosition) - } - }, [updateCurrentHeader]) - useEffect(initHeadingsPosition, [headings]) - useEffect(updateCurrentHeader, [headingsOffsets, documentHeight]) - - const contentBlockRef = useRef(null) - const [ - isScrollToCurrentHeadingHappened, - setIsScrollToCurrentHeadingHappened - ] = useState(false) - useEffect(() => { - if (isScrollToCurrentHeadingHappened) { - return - } - if (!document.location.hash) { - setIsScrollToCurrentHeadingHappened(true) - return - } - if (currentHeadingSlug) { - setIsScrollToCurrentHeadingHappened(true) - const currentHeadingSlugElem = document.getElementById( - `link-${currentHeadingSlug}` - ) - const contentBlockElem = contentBlockRef.current - if (currentHeadingSlugElem && contentBlockElem) { - const hasVerticalScrollbar = - contentBlockElem.scrollHeight > contentBlockElem.clientHeight - if (hasVerticalScrollbar) { - currentHeadingSlugElem.scrollIntoView({ - block: 'start', - inline: 'nearest' - }) - } - } - } - }) - - return ( -
- {headings.length > 0 && ( - <> -
-
Content
-
-
-
- {headings.map(({ slug, text }) => ( - - ))} -
- - )} -
- {Object.keys(tutorials || {}).length > 0 && ( -
-

- - ▶️ - {' '} - It can be run online: -

- -
- )} -
-

- - 🐛 - {' '} - Found an issue? Let us know! Or fix it: -

- - - - Edit on GitHub - -
- -
-

- - ❓ - {' '} - Have a question? Join our chat, we will help you: -

- - - - Discord Chat - -
-
-
- ) -} - -export default RightPanel diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/RightPanel/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/RightPanel/styles.module.css deleted file mode 100644 index fa126a475f..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/RightPanel/styles.module.css +++ /dev/null @@ -1,104 +0,0 @@ -.container { - position: sticky; - top: var(--layout-header-height); - flex-shrink: 0; - box-sizing: border-box; - width: 170px; - height: calc(100vh - 78px); - padding-top: 57px; - font-size: 16px; - display: flex; - flex-direction: column; - - @media only screen and (max-width: 1200px) { - display: none; - } -} - -.contentBlock { - overflow-y: scroll; - margin-bottom: 27px; - - &::-webkit-scrollbar { - appearance: none; - width: 7px; - } - - &::-webkit-scrollbar-thumb { - border-radius: 5px; - background-color: #7e7e7e; - } -} - -.separator { - border: none; - border-top: 1px solid var(--color-lighter-blue); -} - -.header { - font-size: 14px; - text-transform: uppercase; - color: var(--color-black); -} - -.headingLink { - position: relative; - display: block; - min-height: 26px; - margin-bottom: 3px; - color: #a0a8a5; - text-decoration: none; - font-size: 16px; - font-weight: 400; - line-height: 26px; - cursor: pointer; - - &.current { - color: #000; - } - - &:hover { - color: #3c3937; - } -} - -.buttonsBlock { - margin-bottom: 20px; - flex-shrink: 0; -} - -.buttonSection { - & + & { - margin-top: 15px; - } -} - -.buttonSectionIcon { - display: inline-block; - width: 1em; - height: 1em; - margin-right: 5px; -} - -.buttonSectionDescription { - color: var(--color-black); -} - -.button { - width: 100%; - margin: 10px 0; - - &.tutorials { - white-space: nowrap; - } -} - -.githubIcon { - background-image: url("/img/github_icon.svg"); -} - -.discordIcon { - width: 1.2em; - height: 1.2em; - background-image: url("/img/discord.svg"); -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/TutorialsLinks/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/TutorialsLinks/index.tsx deleted file mode 100644 index 2539fec72b..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/TutorialsLinks/index.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react' -import cn from 'classnames' -import topairs from 'lodash/toPairs' -import startCase from 'lodash/startCase' - -import Link from '../../Link' - -import * as sharedStyles from '../styles.module.css' -import * as styles from './styles.module.css' - -interface ITutorialsLinksProps { - compact?: boolean - buttonClassName?: string - tutorials: { [type: string]: string } -} - -const TutorialsLinks: React.FC = ({ - compact = false, - buttonClassName, - tutorials -}) => ( - <> - {topairs(tutorials).map(([type, href]) => { - return ( - - {styles[`${type}Icon`] && ( - - )} - {!compact && `Run in ${startCase(type)}`} - - ) - })} - -) - -export default TutorialsLinks diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/TutorialsLinks/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/TutorialsLinks/styles.module.css deleted file mode 100644 index 33f2341339..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/TutorialsLinks/styles.module.css +++ /dev/null @@ -1,21 +0,0 @@ -.button { - &:not(.compact) { - & + & { - margin-top: 10px; - } - } - - &.compact { - margin-left: 5px; - - .katacodaIcon { - margin-right: 0; - } - } -} - -.katacodaIcon { - width: 24px; - height: 24px; - background-image: url("/img/katacoda_grey_small.png"); -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/AutoLinkElement/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/AutoLinkElement/index.tsx deleted file mode 100644 index d6f3b2fc2b..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/AutoLinkElement/index.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import React from 'react' -import * as styles from './styles.module.css' - -interface IElementProps { - attributes?: Record - el?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' -} - -const Element: React.FC = ({ children, el, attributes }) => { - switch (el) { - case 'h6': - return
{children}
- case 'h5': - return
{children}
- case 'h4': - return

{children}

- case 'h3': - return

{children}

- case 'h2': - return

{children}

- case 'h1': - return

{children}

- default: - return {children} - } -} - -interface IAutoLinkHeaderProps { - id: string - el?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' - anchorStyle?: Record -} - -const AutoLinkElement: React.FC = ({ - children, - id, - el, - anchorStyle -}) => { - return ( - <> - - {children} - - - - - - ) -} - -export default AutoLinkElement diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/AutoLinkElement/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/AutoLinkElement/styles.module.css deleted file mode 100644 index b508b1b7b5..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/AutoLinkElement/styles.module.css +++ /dev/null @@ -1,9 +0,0 @@ -.autoLinkEl { - svg { - visibility: hidden; - } - - &:hover svg { - visibility: visible; - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/index.tsx deleted file mode 100644 index d9c625f2c7..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/WithJSX/index.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react' - -import MarkdownMain from '../Markdown/Main' -import RightPanel from '../RightPanel' - -import { IHeading } from '../' -import { getItemByPath } from '../../../utils/shared/sidebar' -import { getGithubLink } from '../../../getGithubLink' - -interface IWithJSXProps { - path: string - headings: Array -} - -const WithJSX: React.FC = ({ children, path, headings }) => { - const { source, prev, next, tutorials } = getItemByPath(path) - const githubLink = getGithubLink(source) - - return ( - <> - - {children} - - - - ) -} - -export default WithJSX diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/index.tsx deleted file mode 100644 index 00f737e2b6..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/index.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React from 'react' -import { Node } from 'unist' - -import Markdown from './Markdown' -import RightPanel from './RightPanel' - -import { getItemByPath } from '../../utils/shared/sidebar' -import { getGithubLink } from '../../getGithubLink' - -export interface IHeading { - slug: string - text: string -} - -interface IDocumentationProps { - path: string - headings: Array - htmlAst: Node -} - -const Documentation: React.FC = ({ - htmlAst, - path, - headings -}) => { - const { source, prev, next, tutorials } = getItemByPath(path) - const githubLink = getGithubLink(source) - - return ( - <> - - - - ) -} - -export default Documentation diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/Documentation/styles.module.css deleted file mode 100644 index f4bb9eda95..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Documentation/styles.module.css +++ /dev/null @@ -1,35 +0,0 @@ -.button { - position: relative; - z-index: 1; - box-sizing: border-box; - display: inline-flex; - justify-content: center; - align-items: center; - min-height: 36px; - padding: 2px 16px; - border: 1px solid var(--color-gray-dark); - border-radius: 3px; - text-decoration: none; - font-weight: 500; - line-height: 30px; - background-color: white; - color: var(--color-gray-dark); - cursor: pointer; - transition: 0.2s background-color ease-out; - - &:hover, - &:focus { - outline: none; - background-color: var(--color-light-blue); - } -} - -.buttonIcon { - flex-shrink: 0; - width: 1em; - height: 1em; - margin-right: 7px; - background-size: contain; - background-repeat: no-repeat; - background-position: center; -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/HamburgerIcon/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/HamburgerIcon/index.tsx deleted file mode 100644 index caedcea2ca..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/HamburgerIcon/index.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import cn from 'classnames' -import React from 'react' - -import * as styles from './styles.module.css' - -interface IHamburgerProps { - opened?: boolean -} - -const HamburgerIcon: React.FC = ({ opened }) => ( -
-
-
-
-) - -export default HamburgerIcon diff --git a/plugins/gatsby-theme-iterative-docs/src/components/HamburgerIcon/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/HamburgerIcon/styles.module.css deleted file mode 100644 index 8e6e4f4a8e..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/HamburgerIcon/styles.module.css +++ /dev/null @@ -1,32 +0,0 @@ -.wrapper { - display: inline-block; - cursor: pointer; - - &.opened { - transform: translateX(-4px); - } -} - -.line { - width: 22px; - height: 4px; - background-color: #2e3137; - border-radius: 10px; - margin: 5px 0; - transition: 0.4s; - - .opened & { - background-color: var(--color-gray-light); - border-radius: 20px; - width: 27px; - height: 3px; - - &.first { - transform: rotate(-45deg) translateY(6px); - } - - &.second { - transform: rotate(45deg) translateY(-6px); - } - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/LayoutWidthContainer/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/LayoutWidthContainer/index.tsx deleted file mode 100644 index e0cd73cb7e..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/LayoutWidthContainer/index.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react' -import cn from 'classnames' - -import * as styles from './styles.module.css' - -interface ILayoutWidthContainerProps { - className?: string - children?: React.ReactNode - wide?: boolean -} - -const LayoutWidthContainer: React.FC = ({ - className, - children, - wide = false -}) => ( -
- {children} -
-) - -export default LayoutWidthContainer diff --git a/plugins/gatsby-theme-iterative-docs/src/components/LayoutWidthContainer/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/LayoutWidthContainer/styles.module.css deleted file mode 100644 index 5fa6d47f0a..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/LayoutWidthContainer/styles.module.css +++ /dev/null @@ -1,17 +0,0 @@ -.container { - margin: 0 auto; - padding: 0 15px; - max-width: var(--layout-width); - - &.wide { - max-width: var(--layout-width-wide); - } - - @media (--md-scr) { - max-width: 100%; - } - - @media (--xs-scr) { - padding: 0 31px; - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/Link/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/Link/index.tsx deleted file mode 100644 index 87f1eb7ee7..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/Link/index.tsx +++ /dev/null @@ -1,136 +0,0 @@ -import React, { useCallback } from 'react' -import { URL } from 'iso-url' -import { useLocation } from '@reach/router' -import { Link as GatsbyLink } from 'gatsby' -import { getRedirect } from '../../utils/shared/redirects' -import { scrollIntoLayout, getScrollNode } from '../../utils/front/scroll' -import safeQuerySelector from '../../utils/front/safeQuerySelector' - -export type ILinkProps = { - children: React.ReactNode - className?: string - href: string - target?: undefined | '_blank' - state?: unknown - scrollOptions?: Record - optOutPreRedirect?: undefined | true -} & React.AnchorHTMLAttributes - -const PROTOCOL_REGEXP = /^https?:\/\// -const isRelative = (url: string): boolean => !PROTOCOL_REGEXP.test(url) -const isMailto = (url: string): boolean => url.startsWith('mailto:') - -const ResultLinkComponent: React.FC = ({ - href, - children, - rel, - target, - download = false, - ...restProps -}) => { - // Handle all situations where a basic `a` must be used over Gatsby Link - const hrefIsRelative = isRelative(href) - const hrefIsMailto = isMailto(href) - const hrefHasTarget = typeof target === 'string' - // Fragments within the page should be `a`, but links to other pages - // that have anchors should be okay. - const hrefIsRelativeFragment = href.startsWith('#') - - if ( - download || - !hrefIsRelative || - hrefIsMailto || - hrefHasTarget || - hrefIsRelativeFragment - ) { - /* - Change external links without an explicit rel to have 'noopener - noreferrer', but leave explicitly defined rels alone. - Do the same with `target=_blank` - */ - if (!hrefIsRelative) { - if (typeof rel !== 'string') { - rel = 'noopener noreferrer' - } - if (!hrefHasTarget) { - target = '_blank' - } - } - - return ( - - {children} - - ) - } - - return ( - - {children} - - ) -} - -const scrollToHash = (hash: string, scrollOptions = {}): void => { - if (hash) { - scrollIntoLayout(safeQuerySelector(hash), { - waitImages: true, - ...scrollOptions - }) - } -} - -const Link: React.FC = ({ - href, - scrollOptions, - optOutPreRedirect, - ...restProps -}) => { - const currentLocation = useLocation() - - const onClick = useCallback( - (e: React.MouseEvent) => { - if (restProps.onClick) { - restProps.onClick(e) - } - - // Handle local fragments manually, allowing for more control than - // native HTML fragment navigation. - if (href === '#') { - getScrollNode().scrollTop = 0 - } else if (href.startsWith('#')) { - e.preventDefault() - - // We can't navigate by direct usage of @reach/router#navigate because - // gatsby-react-router-scroll will package intercept scroll in this - // case and we will see undesired jump - window.history.pushState(null, '', href) - scrollToHash(href, scrollOptions) - } - }, - [restProps.onClick, currentLocation] - ) - - const location = new URL(href) - - if (location.host === currentLocation.host && !optOutPreRedirect) { - // Replace link href with redirect if it exists - const [, redirectUrl] = getRedirect(location.host, location.pathname) - - if (redirectUrl) { - href = isRelative(redirectUrl) - ? redirectUrl + currentLocation.search - : redirectUrl - } - } - - return -} - -export default Link diff --git a/plugins/gatsby-theme-iterative-docs/src/components/SEO/helper.ts b/plugins/gatsby-theme-iterative-docs/src/components/SEO/helper.ts deleted file mode 100644 index 56812b0bb2..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/SEO/helper.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { getSrc, IGatsbyImageData } from 'gatsby-plugin-image' - -export type MetaProps = JSX.IntrinsicElements['meta'] - -export const getMetaTitle = (title: string): MetaProps[] => { - return [ - { - property: 'og:title', - content: title - }, - { - name: 'twitter:title', - content: title - } - ] -} - -export const getMetaDescription = (description: string): MetaProps[] => { - return [ - { - name: 'description', - content: description - }, - { - property: 'og:description', - content: description - }, - { - name: 'twitter:description', - content: description - } - ] -} - -export const getMetaImage = ( - imageUrl: string, - imageAlt?: string, - imageHeight?: number, - imageWidth?: number -): MetaProps[] => { - return [ - { property: 'og:image', content: imageUrl }, - { name: 'og:image:alt', content: imageAlt }, - { property: 'og:image:width', content: String(imageWidth) }, - { property: 'og:image:height', content: String(imageHeight) }, - { name: 'twitter:image', content: imageUrl }, - { name: 'twitter:image:alt', content: imageAlt } - ] -} - -export const buildMetadata = ( - siteUrl: string, - title?: string, - defaultMetaTitle?: boolean, - description?: string, - keywords?: string, - image?: IGatsbyImageData | string, - imageAlt?: string, - imageHeight?: number, - imageWidth?: number -) => { - const prebuildMeta: MetaProps[] = [] - if (title && !defaultMetaTitle) { - prebuildMeta.push(...getMetaTitle(title)) - } - if (description) { - prebuildMeta.push(...getMetaDescription(description)) - } - if (keywords) { - prebuildMeta.push({ - name: 'keywords', - content: keywords - }) - } - if (image) { - const isStr = typeof image === 'string' - const imageUrl = siteUrl + (isStr ? image : getSrc(image)) - prebuildMeta.push( - ...getMetaImage(imageUrl, imageAlt, imageHeight, imageWidth) - ) - } - return prebuildMeta -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/SEO/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/SEO/index.tsx deleted file mode 100644 index c02d86b351..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/SEO/index.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import React, { useMemo } from 'react' -import Helmet from 'react-helmet' -import { IGatsbyImageData } from 'gatsby-plugin-image' - -import getSiteMeta from '../../queries/siteMeta' -import { buildMetadata, MetaProps } from './helper' - -export interface IPaginatorPageInfo { - currentPage: number - nextPage?: string - previousPage?: string -} - -interface ISEOProps { - title?: string - defaultMetaTitle?: boolean - description?: string - keywords?: string - imageAlt?: string - image?: IGatsbyImageData | string - imageHeight?: number - imageWidth?: number - meta?: MetaProps[] - pageInfo?: IPaginatorPageInfo - children?: React.ReactNode -} - -const SEO: React.FC = ({ - title, - defaultMetaTitle, - description, - keywords, - image, - imageAlt = '', - imageHeight, - imageWidth, - meta = [], - pageInfo, - children -}) => { - const siteMeta = getSiteMeta() - const pageTitle = useMemo(() => { - return pageInfo && pageInfo.currentPage > 1 - ? `${title || siteMeta.title} page ${pageInfo.currentPage}` - : title - }, [title, siteMeta, pageInfo]) - const prebuildMeta = useMemo(() => { - return buildMetadata( - siteMeta.siteUrl, - pageTitle, - defaultMetaTitle, - description, - keywords, - image, - imageAlt, - imageHeight, - imageWidth - ) - }, [ - siteMeta, - pageTitle, - defaultMetaTitle, - description, - keywords, - image, - imageAlt, - imageWidth, - imageHeight - ]) - - return ( - - {children} - - ) -} - -export * from './helper' - -export default SEO diff --git a/plugins/gatsby-theme-iterative-docs/src/components/ShowOnly/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/ShowOnly/index.tsx deleted file mode 100644 index b2bf6fff81..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/ShowOnly/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react' -import cn from 'classnames' - -import * as styles from './styles.module.css' - -interface IShowOnlyProps { - on: 'mobile' | 'desktop' - as?: 'div' | 'span' - className?: string - children: React.ReactNode -} - -const ShowOnly: React.FC = ({ - on, - as: AS = 'div', - className, - children -}) => {children} - -export default ShowOnly diff --git a/plugins/gatsby-theme-iterative-docs/src/components/ShowOnly/styles.module.css b/plugins/gatsby-theme-iterative-docs/src/components/ShowOnly/styles.module.css deleted file mode 100644 index 1ab7295a38..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/ShowOnly/styles.module.css +++ /dev/null @@ -1,15 +0,0 @@ -.mobile { - display: none; - - @media (--xs-scr) { - display: initial; - } -} - -.desktop { - display: initial; - - @media (--xs-scr) { - display: none; - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/discord.svg b/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/discord.svg deleted file mode 100644 index c43f1a8f6a..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/discord.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/github.svg b/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/github.svg deleted file mode 100644 index f696f1edc0..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/github.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/index.tsx b/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/index.tsx deleted file mode 100644 index 1b94da035c..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/index.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import React from 'react' -import Link from '../Link' -import { ReactComponent as TwitterIcon } from './twitter.svg' -import { ReactComponent as GithubIcon } from './github.svg' -import { ReactComponent as LinkedInIcon } from './linkedin.svg' -import { ReactComponent as LinkedInNoBgIcon } from './linkedin-no-bg.svg' -import { ReactComponent as DiscordIcon } from './discord.svg' -import { ReactComponent as YoutubeIcon } from './youtube.svg' - -const icons: { [site: string]: JSX.Element } = { - linkedin: , - linkedinNoBg: , - github: , - twitter: , - discord: , - youtube: -} - -export interface ISocialIcon { - url: string - site?: string - label?: string -} - -export interface ISocialIconProps extends ISocialIcon { - className?: string -} - -/* - Returns a link containing an icon corresponding to the provided site - - Given the situation where either the given link has no site or we don't have - an icon for it, we return null such that nothing is rendered in map - functions. -*/ -const SocialIcon: React.FC = ({ - site, - url, - className, - label -}): JSX.Element | null => { - /* eslint-disable-next-line */ - const icon: JSX.Element = icons[site!] - return icon ? ( - - {icon} - - ) : null -} - -export default SocialIcon diff --git a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/linkedin-no-bg.svg b/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/linkedin-no-bg.svg deleted file mode 100644 index e7a1a2c779..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/linkedin-no-bg.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/linkedin.svg b/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/linkedin.svg deleted file mode 100644 index 5d613c3bbf..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/linkedin.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/twitter.svg b/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/twitter.svg deleted file mode 100644 index 6a12e86c45..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/twitter.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/youtube.svg b/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/youtube.svg deleted file mode 100644 index dcbb126752..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/components/SocialIcon/youtube.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/plugins/gatsby-theme-iterative-docs/src/config/custom-media.js b/plugins/gatsby-theme-iterative-docs/src/config/custom-media.js deleted file mode 100644 index 1e30babccc..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/config/custom-media.js +++ /dev/null @@ -1,19 +0,0 @@ -const screens = { - giant: 1200, - desktop: 1005, - tablet: 768, - phablet: 572, - phone: 376 -} - -module.exports = { - screens, - customMedia: { - '--xxs-scr': `(max-width: ${screens.phone}px)`, - '--xs-scr': `(max-width: ${screens.phablet}px)`, - '--sm-scr': `(max-width: ${screens.tablet}px)`, - '--md-scr': `(max-width: ${screens.desktop - 1}px)`, - '--lg-scr': `(min-width: ${screens.desktop}px)`, - '--xl-scr': `(min-width: ${screens.giant}px)` - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/constants.ts b/plugins/gatsby-theme-iterative-docs/src/constants.ts deleted file mode 100644 index f5307cf6af..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const githubRepo = 'iterative/dvc.org' diff --git a/plugins/gatsby-theme-iterative-docs/src/getGithubLink.ts b/plugins/gatsby-theme-iterative-docs/src/getGithubLink.ts deleted file mode 100644 index 442ec87955..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/getGithubLink.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { githubRepo } from './constants' -export const getGithubLink = (sourcePath: string): string => - `https://github.com/${githubRepo}/blob/master/content${sourcePath}` diff --git a/plugins/gatsby-theme-iterative-docs/src/queries/siteMeta.ts b/plugins/gatsby-theme-iterative-docs/src/queries/siteMeta.ts deleted file mode 100644 index 59b80d1eef..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/queries/siteMeta.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { useStaticQuery, graphql } from 'gatsby' - -interface ISiteMeta { - title: string - description: string - keywords: string - siteUrl: string -} - -export default function siteMeta(): ISiteMeta { - const { - site: { siteMetadata } - } = useStaticQuery( - graphql` - query SiteMetadata { - site { - siteMetadata { - title - description - keywords - siteUrl - } - } - } - ` - ) - - return siteMetadata -} diff --git a/plugins/gatsby-theme-iterative-docs/src/templates/doc.tsx b/plugins/gatsby-theme-iterative-docs/src/templates/doc.tsx deleted file mode 100644 index 35a20ffd61..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/templates/doc.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React from 'react' -import { graphql } from 'gatsby' -import { Node } from 'unist' -import { getItemByPath } from '../utils/shared/sidebar' - -import SEO from '../components/SEO' - -import Documentation from '../components/Documentation' - -interface IDocPageProps { - data: { - page: { - description?: string - title?: string - parent: { - htmlAst: Node - } - } - } - pageContext: { - slug: string - headings: [] - } -} - -const DocPage: React.FC = ({ - data, - pageContext: { slug, headings } -}) => { - const { - page: { - description, - title, - parent: { htmlAst } - } - } = data - - const { label } = getItemByPath(slug) - - return ( - <> - - - - ) -} - -export default DocPage - -export const pageQuery = graphql` - query DocPage($id: String!) { - page: docsPage(id: { eq: $id }) { - description - title - parent { - ... on MarkdownRemark { - htmlAst - } - } - } - } -` diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/accessibility.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/accessibility.ts deleted file mode 100644 index b445b2ac5c..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/accessibility.ts +++ /dev/null @@ -1,14 +0,0 @@ -const handleMouseDownOnce = (): void => { - document.body.classList.remove('user-is-tabbing') - window.removeEventListener('mousedown', handleMouseDownOnce) - // eslint-disable-next-line @typescript-eslint/no-use-before-define - window.addEventListener('keydown', handleFirstTab) -} - -export const handleFirstTab = (e: KeyboardEvent): void => { - if (e.code === 'Tab') { - document.body.classList.add('user-is-tabbing') - window.removeEventListener('keydown', handleFirstTab) - window.addEventListener('mousedown', handleMouseDownOnce) - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/api.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/api.ts deleted file mode 100644 index 2e2426c029..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/api.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { useEffect, useState } from 'react' -import fetch from 'isomorphic-fetch' - -type IApiCallResult = { - error: string | null - ready: boolean - result?: T -} - -type UseApiResult = Omit, 'result'> & { - result?: R -} - -const useAPICall = (url: string): IApiCallResult => { - const [ready, setReady] = useState(false) - const [error, setError] = useState(null) - const [result, setResult] = useState(undefined) - - useEffect(() => { - let cancelled = false - - const fetchData = async (): Promise => { - try { - const res = await fetch(url) - - if (!cancelled) { - if (res.status !== 200) { - setError('Bad response status') - } else { - setResult(await res.json()) - } - } - } catch { - if (!cancelled) setError('Error loading request') - } finally { - if (!cancelled) setReady(true) - } - } - - fetchData() - - return (): void => { - cancelled = true - } - }, []) - - return { error, ready, result } -} - -export interface IGithubIssue { - title: string - url: string - comments: number - date: string -} - -export interface IGithubIssuesResponse { - issues: Array -} - -export function useIssues(): UseApiResult< - IGithubIssuesResponse, - IGithubIssue[] -> { - const response = useAPICall('/api/github/issues') - - return { ...response, result: response.result?.issues } -} - -export interface IDiscussTopic { - title: string - comments: number - date: string - url: string -} - -export interface IDiscussTopicsResponse { - topics: Array -} - -export function useTopics(): UseApiResult< - IDiscussTopicsResponse, - IDiscussTopic[] -> { - const response = useAPICall('/api/discourse') - - return { ...response, result: response.result?.topics } -} - -export interface IDiscussCommentsCountResponse { - count: number -} - -export function useCommentsCount( - commentsUrl: string -): UseApiResult { - const response = useAPICall( - `/api/comments?url=${commentsUrl}` - ) - - return { ...response, result: response.result?.count } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/breakpoints.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/breakpoints.ts deleted file mode 100644 index a7323a7534..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/breakpoints.ts +++ /dev/null @@ -1,12 +0,0 @@ -import includes from 'lodash/includes' -import { customMedia } from '../../config/custom-media' - -type AvailableCustomMedia = keyof typeof customMedia - -export const matchMedia = (media: string | AvailableCustomMedia): boolean => { - if (media.startsWith('--') && includes(Object.keys(customMedia), media)) { - media = customMedia[media as AvailableCustomMedia] - } - - return window.matchMedia(media).matches -} diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/customProperties.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/customProperties.ts deleted file mode 100644 index 9d8872cfc5..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/customProperties.ts +++ /dev/null @@ -1,31 +0,0 @@ -const getCustomProperties = ((): (() => CSSStyleDeclaration) => { - let cssDecl: CSSStyleDeclaration - - return (): CSSStyleDeclaration => { - if (!cssDecl) { - cssDecl = getComputedStyle(document.documentElement, null) - } - - return cssDecl - } -})() - -export const getCustomProperty = ((): ((name: string) => number | string) => { - const IS_PX_VALUE = /px$/ - const cachedValues: { [key: string]: number | string } = {} - - return (name: string): number | string => { - if (!cachedValues[name]) { - const all = getCustomProperties() - const value = all.getPropertyValue(name).trim() - - if (IS_PX_VALUE.test(value)) { - return parseInt(value, 10) - } - - cachedValues[name] = value - } - - return cachedValues[name] - } -})() diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/focusElementWithHotkey.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/focusElementWithHotkey.ts deleted file mode 100644 index 229400670b..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/focusElementWithHotkey.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Utility function to focus on an element by pressing a specified hotkey. - * @param target CSS selector for the element to be focused - * @param hotkey The key that should trigger the target element to be focused - * @returns A function that will remove the event listener (e.g. on component unmount) - */ -export const focusElementWithHotkey = ( - target: string, - hotkey: string -): (() => void) => { - const hotkeyEventHandler = (e: KeyboardEvent): void => { - if (e.key !== hotkey || document.activeElement?.matches(target)) { - return - } - const targetElement = document.querySelector(target) as HTMLElement - targetElement?.focus() - e.preventDefault() - } - document.addEventListener('keydown', hotkeyEventHandler) - return (): void => document.removeEventListener('keydown', hotkeyEventHandler) -} diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/glossary.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/glossary.ts deleted file mode 100644 index 292ff52cbf..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/glossary.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { useStaticQuery, graphql } from 'gatsby' - -interface IGlossaryEntry { - name: string - desc: string - match: Array -} -interface IGlossary { - contents: Array -} - -const useGlossary = (): IGlossary => - useStaticQuery(graphql` - query GlossaryEntries { - allGlossaryEntry { - contents: nodes { - desc: tooltip - name - match - } - } - } - `).allGlossaryEntry - -export default useGlossary diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/i18n.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/i18n.ts deleted file mode 100644 index c642319fcd..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/i18n.ts +++ /dev/null @@ -1,23 +0,0 @@ -export function pluralize( - entry: { zero: string; one: string; other: string }, - count: number -): string { - let selectedEntry - - if (count === 0 && entry.zero) { - selectedEntry = entry.zero - } else if (count === 1) { - selectedEntry = entry.one - } else { - selectedEntry = entry.other - } - - return selectedEntry.replace('{count}', count.toString()) -} - -export function pluralizeComments(count: number): string { - return pluralize( - { zero: 'No comments', one: '{count} comment', other: '{count} comments' }, - count - ) -} diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/images.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/images.ts deleted file mode 100644 index f29081217c..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/images.ts +++ /dev/null @@ -1,28 +0,0 @@ -import Promise from 'promise-polyfill' - -export const getImages = (node: Element): Array => - Array.from(node.querySelectorAll('img')).filter(imgNode => !!imgNode.src) - -export const imageLoaded = (imgNode: HTMLImageElement): Promise => { - if (imgNode.complete && imgNode.naturalWidth !== 0) { - return Promise.resolve() - } - - return new Promise(resolve => { - imgNode.addEventListener('load', function onLoad() { - resolve() - imgNode.removeEventListener('load', onLoad) - }) - imgNode.addEventListener('error', function onError() { - resolve() - imgNode.removeEventListener('error', onError) - }) - }) -} - -export const allImagesLoaded = ( - nodes: Array -): Promise => Promise.all(nodes.map(imageLoaded)) - -export const allImagesLoadedInContainer = (node: Element): Promise => - allImagesLoaded(getImages(node)) diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/isClient.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/isClient.ts deleted file mode 100644 index da2240de90..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/isClient.ts +++ /dev/null @@ -1,12 +0,0 @@ -const IS_CLIENT = ((): boolean => { - let isDefined = false - try { - window - isDefined = true - } catch (x) { - // nothing to do here, move on - } - return isDefined -})() - -export default IS_CLIENT diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/keyboard.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/keyboard.ts deleted file mode 100644 index 4127d10fbd..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/keyboard.ts +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react' - -enum KEYS { - RETURN = 13, - SPACE = 32 -} - -export const isTriggeredFromKB = (e: React.KeyboardEvent): boolean => - e.which === KEYS.RETURN || e.which === KEYS.SPACE diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/plausible.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/plausible.ts deleted file mode 100644 index 812ae34468..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/plausible.ts +++ /dev/null @@ -1,21 +0,0 @@ -declare global { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface Window { - plausible: ( - eventName: string, - props?: { props: { [key: string]: string } } - ) => void - } -} - -export const logEvent = ( - eventName: string, - props?: { [key: string]: string } -): void => { - if (!window.plausible) return - if (props) { - window.plausible(eventName, { props }) - } else { - window.plausible(eventName) - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/resources.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/resources.ts deleted file mode 100644 index 7898d2e0af..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/resources.ts +++ /dev/null @@ -1,64 +0,0 @@ -import Promise from 'promise-polyfill' - -const createScript = ( - src: string, - onload: () => void, - onerror: () => void -): HTMLScriptElement => { - const node = document.createElement('script') - - node.onload = onload - node.onerror = onerror - node.type = 'text/javascript' - node.src = src - - return node -} - -const createStylesheet = ( - href: string, - onload: () => void, - onerror: () => void -): HTMLLinkElement => { - const node = document.createElement('link') - - node.onload = onload - node.onerror = onerror - node.rel = 'stylesheet' - node.type = 'text/css' - node.media = 'all' - node.href = href - - return node -} - -const resourcesCache: { [url: string]: Promise } = {} -const resourceNodeCreators: { - [regex: string]: typeof createScript | typeof createStylesheet -} = { - '\\.js$': createScript, - '\\.css$': createStylesheet -} - -export const loadResource = (url: string): Promise => { - if (!resourcesCache[url]) { - resourcesCache[url] = new Promise((resolve, reject) => { - const howToHandle = Object.keys(resourceNodeCreators).find(regExp => - new RegExp(regExp).test(url) - ) - - if (!howToHandle) { - throw new Error(`You can't load resource with this url: ${url}`) - } - - const creator = resourceNodeCreators[howToHandle] - - if (creator) { - const node = creator(url, resolve, reject) - document.head.appendChild(node) - } - }) - } - - return resourcesCache[url] -} diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/safeQuerySelector.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/safeQuerySelector.ts deleted file mode 100644 index 111b910f78..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/safeQuerySelector.ts +++ /dev/null @@ -1,10 +0,0 @@ -const safeQuerySelector = (query: string): null | Element => { - try { - const el = document.querySelector(query) - return el - } catch (err) { - return null - } -} - -export default safeQuerySelector diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/scroll.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/scroll.ts deleted file mode 100644 index ef50612c79..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/scroll.ts +++ /dev/null @@ -1,81 +0,0 @@ -import scroll from 'scroll' -import { useWindowScroll } from 'react-use' -export { default as ease } from 'ease-component' - -import { getCustomProperty } from './customProperties' -import isClient from './isClient' -import { allImagesLoadedInContainer } from './images' - -const CONTENT_ROOT_ID = 'layoutContent' -const COLLAPSE_HEADER_AFTER = 25 - -const headerIsCollapsedAt = (scrollPosition: number): boolean => - scrollPosition > COLLAPSE_HEADER_AFTER - -export const getScrollPosition = (): number => - isClient ? window.pageYOffset : 0 - -export const getScrollNode = (): Element => - document.scrollingElement || document.documentElement - -export const getHeaderHeightAt = (): number => { - const header = getCustomProperty('--layout-header-height') - - return header as number -} - -export const getHeaderHeight = (): number => getHeaderHeightAt() - -export const useHeaderIsScrolled = (): boolean => { - const { y } = useWindowScroll() - - return headerIsCollapsedAt(y) -} - -type ScrollOptions = { - offset?: number - waitImages?: boolean -} & { - smooth?: true - duration?: number - ease?: (value: number) => number -} - -const scrollToPosition = (node: Element, opts?: ScrollOptions): void => { - const htmlNode = getScrollNode() - const nodeOffset = node.getBoundingClientRect() - const nodePosition = htmlNode.scrollTop + nodeOffset.top + (opts?.offset || 0) - // const headerHeight = getHeaderHeightAt(nodePosition) - const headerHeight = getHeaderHeightAt() - const scrollTo = Math.floor(nodePosition - headerHeight) - - if (!opts?.smooth) { - requestAnimationFrame(() => (htmlNode.scrollTop = scrollTo)) - return - } - - scroll.top(htmlNode, scrollTo, { - duration: opts?.duration, - ease: opts?.ease - }) -} - -export const scrollIntoLayout = ( - node: Element | null, - opts?: ScrollOptions -): void => { - if (!node) { - return - } - - if (!opts?.waitImages) { - return scrollToPosition(node, opts) - } - - const contentRoot = document.getElementById(CONTENT_ROOT_ID) - if (contentRoot) { - allImagesLoadedInContainer(contentRoot).then(() => - scrollToPosition(node, opts) - ) - } -} diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/front/useCustomYtEmbeds.ts b/plugins/gatsby-theme-iterative-docs/src/utils/front/useCustomYtEmbeds.ts deleted file mode 100644 index dc5e74b822..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/front/useCustomYtEmbeds.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { useEffect } from 'react' - -const hideAllEmbedOverlays = (embeds: NodeListOf) => { - embeds.forEach(embed => { - const overlay = embed.querySelector('.yt-embed-wrapper__overlay') - overlay?.classList.add('hidden') - }) -} - -const setUpEmbedClickListeners = (embeds: NodeListOf) => { - const removeClickListeners: Array<() => void> = [] - - embeds.forEach(embed => { - const iframe = embed.querySelector('iframe') - const overlay = embed.querySelector('.yt-embed-wrapper__overlay') - const tooltip = embed.querySelector('.yt-embed-wrapper__tooltip') - - const handleOverlayClick = (event: MouseEvent) => { - if (event.target === tooltip || tooltip?.contains(event.target as Node)) { - return - } - - if (iframe && iframe.src) { - iframe.src = iframe?.src + `&autoplay=1` - } - hideAllEmbedOverlays(embeds) - localStorage.setItem('yt-embed-consent', 'true') - } - const removeListener = () => { - overlay?.removeEventListener('click', handleOverlayClick as EventListener) - } - overlay?.addEventListener('click', handleOverlayClick as EventListener) - removeClickListeners.push(removeListener) - }) - - return () => { - removeClickListeners.forEach(rmListener => rmListener()) - } -} - -const useCustomYtEmbeds = () => { - useEffect(() => { - const hasUserGivenConsent = Boolean( - localStorage.getItem('yt-embed-consent') - ) - const embeds = document.querySelectorAll('.yt-embed-wrapper') - - if (hasUserGivenConsent) { - hideAllEmbedOverlays(embeds) - return - } - - const cleanUpEventListeners = setUpEmbedClickListeners(embeds) - - return () => { - cleanUpEventListeners() - } - }, []) -} - -export default useCustomYtEmbeds diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/shared/redirects.js b/plugins/gatsby-theme-iterative-docs/src/utils/shared/redirects.js deleted file mode 100644 index f40671c204..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/shared/redirects.js +++ /dev/null @@ -1,96 +0,0 @@ -/* eslint-env node */ - -const { navigate } = require('@reach/router') -const { structure, findChildWithSource } = require('./sidebar') -const redirects = require('../../../redirects') - -const buildSidebarRedirects = (list, redirects = []) => { - list.forEach(item => { - if (!item.source && item.children) { - const redirectToChild = findChildWithSource(item) - - redirects.push(`^${item.path}/?$ ${redirectToChild.path} 307`) - } - - if (Array.isArray(item.children)) { - buildSidebarRedirects(item.children, redirects) - } - }) - - return redirects -} - -const processRedirectString = redirectString => { - const redirectParts = redirectString.split(/\s+/g) - const matchPathname = /^\^?\//.test(redirectParts[0]) - const regex = new RegExp(redirectParts[0]) - - return { - regex, - matchPathname, - replace: redirectParts[1], - code: Number(redirectParts[2] || 301) - } -} - -const getRedirects = (() => { - let allRedirects - - return () => { - if (!allRedirects) { - allRedirects = [...redirects, ...buildSidebarRedirects(structure)].map( - processRedirectString - ) - } - - return allRedirects - } -})() - -const matchRedirectList = (host, pathname) => { - const wholeUrl = `https://${host}${pathname}` - - for (const { matchPathname, regex, replace, code } of getRedirects()) { - const matchTarget = matchPathname ? pathname : wholeUrl - if (regex.test(matchTarget)) { - return [code, matchTarget.replace(regex, replace).replace(/^\/+/, '/')] - } - } - - return [] -} - -const getRedirect = (host, pathname, { req, dev } = {}) => { - const httpsRedirect = req != null && !dev && !/^localhost(:\d+)?$/.test(host) - if (httpsRedirect && req.headers['x-forwarded-proto'] !== 'https') { - return [301, `https://${host.replace(/^www\./, '')}${req.url}`] - } - - return matchRedirectList(host, pathname) -} - -const handleFrontRedirect = (host, pathname, clickEvent) => { - let [, redirectUrl] = getRedirect(host, pathname) - - if (redirectUrl) { - if (clickEvent) { - clickEvent.preventDefault() - } - - if (redirectUrl.startsWith('/')) { - redirectUrl = redirectUrl + location.search - - // If it's trailing slash redirect we should save hash in the url - if (pathname === `${redirectUrl}/`) { - redirectUrl = redirectUrl + location.hash - } - } - - navigate(redirectUrl) - } -} - -exports.buildSidebarRedirects = buildSidebarRedirects -exports.processRedirectString = processRedirectString -exports.getRedirect = getRedirect -exports.handleFrontRedirect = handleFrontRedirect diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/shared/redirects.test.js b/plugins/gatsby-theme-iterative-docs/src/utils/shared/redirects.test.js deleted file mode 100644 index 0719960edd..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/shared/redirects.test.js +++ /dev/null @@ -1,248 +0,0 @@ -const url = require('url') -const { - buildSidebarRedirects, - processRedirectString, - getRedirect -} = require('./redirects') - -describe('buildRedirectsList', () => { - it('builds correct redirects list', () => { - const list = [ - { - source: false, - path: '/a', - children: [ - { - path: '/a/b', - source: 'some-file' - } - ] - } - ] - - expect(buildSidebarRedirects(list)).toEqual(['^/a/?$ /a/b 307']) - }) -}) - -describe('processRedirectString', () => { - it('reads the regex, replacement and code', () => { - const { regex, replace, code } = processRedirectString('^/foo /bar 418') - - expect(regex).toBeInstanceOf(RegExp) - expect(regex.source).toEqual('^\\/foo') - expect(replace).toEqual('/bar') - expect(code).toEqual(418) - }) - - it('defaults to 301 response code', () => { - const { code } = processRedirectString('^/x /y') - - expect(code).toEqual(301) - }) - - it('detects whether redirecting a full URL or just a path', () => { - const { matchPathname: matchPathnameFalse } = processRedirectString( - '^https://example.com/foo /x' - ) - expect(matchPathnameFalse).toEqual(false) - - const { matchPathname } = processRedirectString('^/path /y') - expect(matchPathname).toEqual(true) - }) -}) - -describe('getRedirects', () => { - it('enforces HTTPS and removes www simultaneously', () => { - const mockReq = { - headers: { - 'x-forwarded-proto': 'http' - }, - url: '/foo/bar?baz' - } - expect( - getRedirect('www.dvc.org', '/not-used', { req: mockReq, dev: false }) - ).toEqual([301, 'https://dvc.org/foo/bar?baz']) - }) - - const itRedirects = (source, target, code = 301) => { - const addHost = pathOrUrl => { - if (pathOrUrl.startsWith('/')) { - return `https://dvc.org${pathOrUrl}` - } - return pathOrUrl - } - - it(`${source} -> ${target} (${code})`, () => { - source = addHost(source) - const { hostname, pathname } = url.parse(source) - const [rCode, rLocation] = getRedirect(hostname, pathname) - - expect(rLocation).toEqual(target) - expect(rCode).toEqual(code) - - // Detect redirect loops. - const secondUrl = url.parse(addHost(rLocation)) - const secondRedirect = getRedirect(secondUrl.hostname, secondUrl.pathname) - - // allow second redirect only if it removes trailing slash - if (secondRedirect.length) { - const thirdUrl = url.parse(addHost(secondRedirect[1])) - expect(secondUrl.host).toEqual(thirdUrl.host) - expect(secondUrl.pathname.replace(/\/$/, '')).toEqual(secondRedirect[1]) - - const thirdRedirect = getRedirect(thirdUrl.hostname, thirdUrl.pathname) - expect(thirdRedirect).toEqual([]) - } - }) - } - - describe('fromSubdomains', () => { - // Remove www (when already HTTPS) - itRedirects('https://www.dvc.org/foo', 'https://dvc.org/foo') - - itRedirects( - 'https://man.dvc.org/', - 'https://dvc.org/doc/command-reference/', - 303 - ) - - itRedirects( - 'https://man.dvc.org/foo', - 'https://dvc.org/doc/command-reference/foo', - 303 - ) - - itRedirects( - 'https://error.dvc.org/', - 'https://dvc.org/doc/user-guide/troubleshooting#', - 303 - ) - - itRedirects( - 'https://error.dvc.org/foo', - 'https://dvc.org/doc/user-guide/troubleshooting#foo', - 303 - ) - - itRedirects( - 'https://www.dataversioncontrol.com/some-random', - 'https://dvc.org/some-random', - 301 - ) - - itRedirects('https://www.dataversioncontrol.com', 'https://dvc.org/', 301) - - itRedirects( - 'https://dataversioncontrol.com/some-random', - 'https://dvc.org/some-random', - 301 - ) - - itRedirects( - 'https://discuss.dataversioncontrol.com/some-random', - 'https://discuss.dvc.org/some-random', - 301 - ) - - itRedirects( - 'https://blog.dataversioncontrol.com/september-19-dvc-heartbeat-0123456789ab', - 'https://dvc.org/blog/september-19-dvc-heartbeat', - 301 - ) - - itRedirects( - 'https://blog.dataversioncontrol.com/some-random', - 'https://dvc.org/blog/some-random', - 301 - ) - - itRedirects( - 'https://blog.dataversioncontrol.com', - 'https://dvc.org/blog/', - 301 - ) - - itRedirects( - 'https://blog.dvc.org/september-19-dvc-heartbeat', - 'https://dvc.org/blog/september-19-dvc-heartbeat', - 301 - ) - - itRedirects('https://blog.dvc.org', 'https://dvc.org/blog/', 301) - }) - - describe('toS3', () => { - itRedirects( - 'https://code.dvc.org/foo/bar', - 'https://s3-us-east-2.amazonaws.com/dvc-public/code/foo/bar', - 303 - ) - - itRedirects( - 'https://data.dvc.org/foo/bar', - 'https://s3-us-east-2.amazonaws.com/dvc-public/data/foo/bar', - 303 - ) - - itRedirects( - 'https://remote.dvc.org/foo/bar', - 'https://s3-us-east-2.amazonaws.com/dvc-public/remote/foo/bar', - 303 - ) - - itRedirects( - '/exe/foo', - 'https://s3-us-east-2.amazonaws.com/dvc-public/dvc-pkgs/exe/foo', - 303 - ) - - itRedirects( - '/deb/foo', - 'https://s3-us-east-2.amazonaws.com/dvc-s3-repo/deb/foo', - 303 - ) - - itRedirects( - '/rpm/foo', - 'https://s3-us-east-2.amazonaws.com/dvc-s3-repo/rpm/foo', - 303 - ) - }) - - describe('toDiscord', () => { - itRedirects('/help', 'https://discordapp.com/invite/dvwXA2N', 303) - - itRedirects('/chat', 'https://discordapp.com/invite/dvwXA2N', 303) - }) - - describe('fromPaths', () => { - itRedirects('/docs/x', '/doc/x') - - itRedirects('/documentation/x', '/doc/x') - - itRedirects('/doc/commands-reference/foo', '/doc/command-reference/foo') - - itRedirects('/doc/tutorial', '/doc/start') - itRedirects('/doc/tutorial/', '/doc/start') - itRedirects('/doc/tutorials', '/doc/start') - itRedirects('/doc/tutorials/', '/doc/start') - itRedirects('/doc/tutorials/deep', '/doc/start') - itRedirects( - '/doc/tutorials/versioning', - '/doc/use-cases/versioning-data-and-model-files/tutorial' - ) - - itRedirects('/doc/tutorial/bar', '/doc/start') - - itRedirects( - '/doc/use-cases/data-and-model-files-versioning', - '/doc/use-cases/versioning-data-and-model-files' - ) - }) - - describe('Does not accidentally redirect to an external site', () => { - itRedirects('//google.com/', '/google.com') - itRedirects('https://dvc.org//google.com/', '/google.com') - itRedirects('/////////evil.com/', '/evil.com') - }) -}) diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar.js b/plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar.js deleted file mode 100644 index 4ac64503e7..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar.js +++ /dev/null @@ -1,236 +0,0 @@ -/* eslint-env node */ -/* - These helpers normalize sidebar structure and create all the resources needed. - This prevents future recalculations. - - Target structure example: - - { - label: "Add Files or Directories", - path: "/doc/start/add-files", - source: "/doc/start/add-files.md", - prev: "/doc/start/configure", - next: "/doc/start/share-data", - icon: "house", - style: "customClass", - tutorials: { - katacoda: "https://www.katacoda.com/dvc/courses/get-started" - } - children: [] - } -*/ - -const { titleCase } = require('title-case') -const sidebar = require('../../../sidebar') - -const PATH_ROOT = '/doc' -const FILE_ROOT = '/docs/' -const FILE_EXTENSION = '.md' - -function dvcTitleCase(slug) { - return titleCase(slug.replace(/dvc/g, 'DVC').replace(/-/g, ' ')) -} - -function validateRawItem({ slug, source, children, type, url }) { - const isSourceDisabled = source === false - - switch (type) { - case 'external': - if (typeof url !== 'string') { - throw Error("'url' field is required in external sidebar.json entries") - } - break - default: - if (typeof slug !== 'string') { - throw Error("'slug' field is required in local sidebar.json entries") - } - - if (isSourceDisabled && (!children || !children.length)) { - throw Error( - 'Local sidebar.json entries with no source must have children' - ) - } - } -} - -function findItemByField(data, field, targetValue) { - if (data.length) { - for (let i = 0; i < data.length; i++) { - const { children } = data[i] - - if (data[i][field] === targetValue) { - return data[i] - } else if (children) { - const result = findItemByField(children, field, targetValue) - if (result) { - return result - } - } - } - } -} - -function findPrevItemWithSource(data, item) { - if (item && item.source) { - return item - } else if (item && item.prev) { - const prevItem = findItemByField(data, 'path', item.prev) - - return findPrevItemWithSource(data, prevItem) - } -} - -function normalizeItem({ rawItem, parentPath, resultRef, prevRef }) { - validateRawItem(rawItem) - - const { label, slug, source, tutorials, type, url, style, icon } = rawItem - - const sharedFields = { - style, - icon - } - - switch (type) { - case 'external': - return { - type, - path: url, - label, - ...sharedFields - } - default: - // If prev item doesn't have source we need to search for it - const prevItemWithSource = - prevRef && findPrevItemWithSource(resultRef, prevRef) - - const prev = prevItemWithSource && prevItemWithSource.path - - const sourceFileName = source ? source : slug + FILE_EXTENSION - const sourcePath = FILE_ROOT + parentPath + sourceFileName - - const relativePath = parentPath + slug - - return { - path: relativePath ? `${PATH_ROOT}/${relativePath}` : PATH_ROOT, - source: source === false ? false : sourcePath, - label: label ? label : dvcTitleCase(slug), - tutorials: tutorials || {}, - prev, - next: undefined, - ...sharedFields - } - } -} - -function normalizeSidebar({ - data, - parentPath, - parentResultRef, - startingPrevRef -}) { - const currentResult = [] - const resultRef = parentResultRef || currentResult - let prevRef = startingPrevRef - - data.forEach(rawItem => { - const isShortcut = typeof rawItem === 'string' - rawItem = isShortcut ? { slug: rawItem } : rawItem - const normalizedItem = normalizeItem({ - rawItem, - parentPath, - resultRef, - prevRef - }) - - if (prevRef) { - prevRef.next = normalizedItem.path - } - - if (rawItem.children) { - normalizedItem.children = normalizeSidebar({ - data: rawItem.children, - parentPath: `${parentPath}${rawItem.slug}/`, - parentResultRef: resultRef, - startingPrevRef: normalizedItem - }) - - prevRef = normalizedItem.children[normalizedItem.children.length - 1] - } else { - prevRef = normalizedItem - } - - currentResult.push(normalizedItem) - }) - - return currentResult -} - -/* - * Exports - */ - -const normalizedSidebar = normalizeSidebar({ - data: sidebar, - parentPath: '' -}) - -function findChildWithSource(item) { - // Return item unchanged if isn't root-relative - if (!item.path.startsWith('/')) return item - return item.source - ? item - : findChildWithSource(item.children && item.children[0]) -} - -function getFirstPage() { - return findChildWithSource(normalizedSidebar[0]).path -} - -function getItemByPath(path) { - const normalizedPath = path.replace(/\/$/, '') - const isRoot = normalizedPath === PATH_ROOT - const item = isRoot - ? normalizedSidebar[0] - : findItemByField(normalizedSidebar, 'path', normalizedPath) - - if (!item) return false - - return findChildWithSource(item) -} - -function getItemBySource(source) { - const item = findItemByField(normalizedSidebar, 'source', source) - - return item || false -} - -function getPathWithSource(path) { - return getItemByPath(path).path -} -function getParentsListFromPath(path) { - // If path is the homepage, indicate that it's the only one active. - // This will have to change if we add children under home, but we don't currently. - if (path === PATH_ROOT) return [PATH_ROOT] - - let currentPath = PATH_ROOT - - return path - .replace(PATH_ROOT + '/', '') - .split('/') - .map(part => { - const path = `${currentPath}/${part}` - currentPath = path - - return path - }) -} - -module.exports = { - structure: normalizedSidebar, - findChildWithSource, - getItemByPath, - getItemBySource, - getPathWithSource, - getParentsListFromPath, - getFirstPage -} diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar.test.js b/plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar.test.js deleted file mode 100644 index 06db04d286..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/shared/sidebar.test.js +++ /dev/null @@ -1,400 +0,0 @@ -/* eslint-env jest */ - -describe('normalizeSidebar', () => { - beforeEach(() => { - jest.resetModules() - }) - - describe('default', () => { - it('Resolves shortcuts to full syntax', () => { - const rawData = ['item-name'] - const result = [ - { - label: 'Item Name', - path: '/doc/item-name', - source: '/docs/item-name.md', - tutorials: {}, - prev: undefined, - next: undefined - } - ] - - jest.doMock('../../../sidebar', () => rawData) - const sidebarData = require('./sidebar').structure - - expect(sidebarData).toEqual(result) - }) - - it('Adds missed source and label fields', () => { - const rawData = [{ slug: 'item-name' }] - const result = [ - { - label: 'Item Name', - path: '/doc/item-name', - source: '/docs/item-name.md', - tutorials: {}, - prev: undefined, - next: undefined - } - ] - - jest.doMock('../../../sidebar', () => rawData) - const sidebarData = require('./sidebar').structure - - expect(sidebarData).toEqual(result) - }) - - it('Adds missed source field', () => { - const rawData = [{ slug: 'item-name', label: 'Custom Label' }] - const result = [ - { - label: 'Custom Label', - path: '/doc/item-name', - source: '/docs/item-name.md', - tutorials: {}, - prev: undefined, - next: undefined - } - ] - - jest.doMock('../../../sidebar', () => rawData) - const sidebarData = require('./sidebar').structure - - expect(sidebarData).toEqual(result) - }) - - it('Adds missed label field', () => { - const rawData = [{ slug: 'item-name', source: 'item-name/index.md' }] - const result = [ - { - label: 'Item Name', - path: '/doc/item-name', - source: '/docs/item-name/index.md', - tutorials: {}, - prev: undefined, - next: undefined - } - ] - - jest.doMock('../../../sidebar', () => rawData) - const sidebarData = require('./sidebar').structure - - expect(sidebarData).toEqual(result) - }) - - it('Forwards tutorials', () => { - const rawData = [ - { - slug: 'item-name', - tutorials: { - katacoda: 'https://www.katacoda.com/dvc/courses/get-started' - } - } - ] - const result = [ - { - label: 'Item Name', - path: '/doc/item-name', - source: '/docs/item-name.md', - tutorials: { - katacoda: 'https://www.katacoda.com/dvc/courses/get-started' - }, - prev: undefined, - next: undefined - } - ] - - jest.doMock('../../../sidebar', () => rawData) - const sidebarData = require('./sidebar').structure - - expect(sidebarData).toEqual(result) - }) - - it('Resolves multiple nested levels', () => { - const rawData = [ - { - slug: 'item-name', - children: [{ slug: 'nested-item', children: ['subnested-item'] }] - } - ] - const result = [ - { - label: 'Item Name', - path: '/doc/item-name', - source: '/docs/item-name.md', - tutorials: {}, - prev: undefined, - next: '/doc/item-name/nested-item', - children: [ - { - label: 'Nested Item', - path: '/doc/item-name/nested-item', - source: '/docs/item-name/nested-item.md', - tutorials: {}, - prev: '/doc/item-name', - next: '/doc/item-name/nested-item/subnested-item', - children: [ - { - label: 'Subnested Item', - path: '/doc/item-name/nested-item/subnested-item', - source: '/docs/item-name/nested-item/subnested-item.md', - tutorials: {}, - prev: '/doc/item-name/nested-item', - next: undefined - } - ] - } - ] - } - ] - - jest.doMock('../../../sidebar', () => rawData) - const sidebarData = require('./sidebar').structure - - expect(sidebarData).toEqual(result) - }) - - it('Adds correct prev/next links in nested list', () => { - const rawData = [ - { slug: 'first-item', children: ['nested-item'] }, - 'second-item' - ] - const result = [ - { - label: 'First Item', - path: '/doc/first-item', - source: '/docs/first-item.md', - tutorials: {}, - prev: undefined, - next: '/doc/first-item/nested-item', - children: [ - { - label: 'Nested Item', - path: '/doc/first-item/nested-item', - source: '/docs/first-item/nested-item.md', - tutorials: {}, - prev: '/doc/first-item', - next: '/doc/second-item' - } - ] - }, - { - label: 'Second Item', - path: '/doc/second-item', - source: '/docs/second-item.md', - tutorials: {}, - prev: '/doc/first-item/nested-item', - next: undefined - } - ] - - jest.doMock('../../../sidebar', () => rawData) - const sidebarData = require('./sidebar').structure - - expect(sidebarData).toEqual(result) - }) - - it('Adds correct prev/next links for sourceless items', () => { - const rawData = [ - 'first-item', - { slug: 'second-item', source: false, children: ['nested-item'] } - ] - const result = [ - { - label: 'First Item', - path: '/doc/first-item', - source: '/docs/first-item.md', - tutorials: {}, - prev: undefined, - next: '/doc/second-item' - }, - { - label: 'Second Item', - path: '/doc/second-item', - source: false, - tutorials: {}, - prev: '/doc/first-item', - next: '/doc/second-item/nested-item', - children: [ - { - label: 'Nested Item', - path: '/doc/second-item/nested-item', - source: '/docs/second-item/nested-item.md', - tutorials: {}, - prev: '/doc/first-item', - next: undefined - } - ] - } - ] - - jest.doMock('../../../sidebar', () => rawData) - const sidebarData = require('./sidebar').structure - - expect(sidebarData).toEqual(result) - }) - - it('Adds correct prev/next links for nested sourceless items', () => { - const rawData = [ - 'first-item', - { - slug: 'second-item', - source: false, - children: [ - { slug: 'nested-item', source: false, children: ['subnested-item'] } - ] - } - ] - const result = [ - { - label: 'First Item', - path: '/doc/first-item', - source: '/docs/first-item.md', - tutorials: {}, - prev: undefined, - next: '/doc/second-item' - }, - { - label: 'Second Item', - path: '/doc/second-item', - source: false, - tutorials: {}, - prev: '/doc/first-item', - next: '/doc/second-item/nested-item', - children: [ - { - label: 'Nested Item', - path: '/doc/second-item/nested-item', - source: false, - tutorials: {}, - prev: '/doc/first-item', - next: '/doc/second-item/nested-item/subnested-item', - children: [ - { - label: 'Subnested Item', - path: '/doc/second-item/nested-item/subnested-item', - source: '/docs/second-item/nested-item/subnested-item.md', - tutorials: {}, - prev: '/doc/first-item', - next: undefined - } - ] - } - ] - } - ] - - jest.doMock('../../../sidebar', () => rawData) - const sidebarData = require('./sidebar').structure - - expect(sidebarData).toEqual(result) - }) - - it("Throws error if external item doesn't have a url field", () => { - const rawData = [{ type: 'external' }] - - jest.doMock('../../../sidebar', () => rawData) - - expect(() => require('./sidebar')).toThrow( - new Error("'url' field is required in external sidebar.json entries") - ) - }) - - it("Throws error if local item doesn't have slug field", () => { - const rawData = [{}] - - jest.doMock('../../../sidebar', () => rawData) - - expect(() => require('./sidebar')).toThrow( - new Error("'slug' field is required in local sidebar.json entries") - ) - }) - - // eslint-disable-next-line max-len - it("Throws error if item has source: false and doesn't have children", () => { - const rawData = [{ slug: 'item-name', source: false }] - - jest.doMock('../../../sidebar', () => rawData) - - expect(() => require('./sidebar')).toThrow( - new Error( - 'Local sidebar.json entries with no source must have children' - ) - ) - }) - }) - - describe('getItemByPath', () => { - it('Returns first child for the /doc path', () => { - const rawData = ['item-name'] - const result = { - label: 'Item Name', - path: '/doc/item-name', - source: '/docs/item-name.md', - tutorials: {}, - prev: undefined, - next: undefined - } - - jest.doMock('../../../sidebar', () => rawData) - const { getItemByPath } = require('./sidebar') - - expect(getItemByPath('/doc')).toEqual(result) - }) - - // eslint-disable-next-line max-len - it('Returns first child with source for all parents with source:false', () => { - const rawData = [ - { - slug: 'item', - source: false, - children: [ - { - slug: 'nested', - source: false, - children: [ - { - slug: 'subnested', - source: false, - children: ['leaf-item'] - } - ] - } - ] - } - ] - const result = { - label: 'Leaf Item', - path: '/doc/item/nested/subnested/leaf-item', - source: '/docs/item/nested/subnested/leaf-item.md', - tutorials: {}, - prev: undefined, - next: undefined - } - - jest.doMock('../../../sidebar', () => rawData) - const { getItemByPath } = require('./sidebar') - - expect(getItemByPath('/doc/item')).toEqual(result) - expect(getItemByPath('/doc/item/nested')).toEqual(result) - expect(getItemByPath('/doc/item/nested/subnested')).toEqual(result) - }) - }) - - describe('getParentsListFromPath', () => { - it("Returns array of current and parent's paths", () => { - const rawData = [] - const path = '/doc/item-name/nested-item/subnested-item' - const result = [ - '/doc/item-name', - '/doc/item-name/nested-item', - '/doc/item-name/nested-item/subnested-item' - ] - - jest.doMock('../../../sidebar', () => rawData) - const { getParentsListFromPath } = require('./sidebar') - - expect(getParentsListFromPath(path)).toEqual(result) - }) - }) -}) diff --git a/plugins/gatsby-theme-iterative-docs/src/utils/shared/tagToSlug.js b/plugins/gatsby-theme-iterative-docs/src/utils/shared/tagToSlug.js deleted file mode 100644 index fa4fd729cc..0000000000 --- a/plugins/gatsby-theme-iterative-docs/src/utils/shared/tagToSlug.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = tag => - tag.trim().toLowerCase().replace(/\s/g, '-').replace(/-+/g, '-') diff --git a/plugins/resize-image-plugin/constants.js b/plugins/resize-image-plugin/constants.js deleted file mode 100644 index 3eed531de3..0000000000 --- a/plugins/resize-image-plugin/constants.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - imageWrapClassPrefix: 'image-wrap-', - imageWrapStopClass: 'image-wrap-stop', - stopWrapTag: 'stop-wrap' -} diff --git a/plugins/resize-image-plugin/index.js b/plugins/resize-image-plugin/index.js deleted file mode 100644 index e47939ba6a..0000000000 --- a/plugins/resize-image-plugin/index.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - Support for resize image inline on markdown - Syntax "=WIDTH", ":wrap-left" and ":wrap-right" - - Examples - ![](/relative-path-image "=500") - ![](/relative-path-image "=500 Some Title") - ![](/relative-path-image "Some Title =500") - ![](/relative-path-image "Some Title :wrap-left =500") - ![](/relative-path-image ":wrap-left =500 Some Title") -*/ - -const visit = require('unist-util-visit') -const { selectAll, select } = require('hast-util-select') -const { - imageClass, - imageWrapperClass -} = require('gatsby-remark-images/constants') - -const { BLOG } = require('../../src/consts') - -const { - imageWrapClassPrefix, - imageWrapStopClass, - stopWrapTag -} = require('./constants') - -const { convertHtmlToHast, convertHastToHtml } = require('../utils/convertHast') - -const extractInstructions = titleString => { - const regexResize = /=\d{2,4}/g - const regexWrap = /:wrap-(left|right)/ - - const title = titleString - .replace(regexResize, '') - .replace(regexWrap, '') - .trim() - const resize = titleString.match(regexResize) - const wrap = titleString.match(regexWrap) - - return { - resize: resize ? Number(resize[0].replace('=', '')) : null, - title, - wrap: wrap ? wrap[1] : null - } -} - -module.exports = ({ markdownAST }) => { - visit(markdownAST, 'html', node => { - const regexMaxWidth = /max-width: \d{1,5}px/g - const hast = convertHtmlToHast(node.value) - const wrapperImageList = selectAll(`.${imageWrapperClass}`, hast) - - if (!wrapperImageList.length) { - return - } - - /* - Image related HTML produced by Gatsby looks like: - - - - - - - - ... - ... - */ - wrapperImageList.forEach(wrapperImage => { - const source = select(`picture > source:first-child`, wrapperImage) - const image = select(`.${imageClass}`, wrapperImage) - const { resize, title, wrap } = extractInstructions( - image.properties.title - ) - - if (resize || wrap) { - // by default Gatsby populates title value with alt, - // restoring it here if needed - image.properties.title = title ? title : image.properties.alt - } - - const originalSize = source.properties.srcSet[ - source.properties.srcSet.length - 1 - ] - .split(' ')[1] - .replace('w', '') - - const maxWidth = wrapperImage.properties.style - .match(regexMaxWidth)[0] - .replace(/\D/g, '') - - if (wrap) { - const { className, style } = wrapperImage.properties - wrapperImage.properties.className = `${ - className || '' - } ${imageWrapClassPrefix}${wrap}` - - // Prevent us from using an !important in the CSS - wrapperImage.properties.style = style.replace( - /margin-(left|right):\s+auto/g, - '' - ) - } - - if (resize || BLOG.imageMaxWidth * 2 > originalSize) { - wrapperImage.properties.style = wrapperImage.properties.style.replace( - regexMaxWidth, - `max-width: ${ - resize ? Math.min(resize, maxWidth) : originalSize / 2 - }px` - ) - } - }) - - const stopWrapTagList = selectAll(stopWrapTag, hast) - stopWrapTagList.forEach(stopWrap => { - stopWrap.tagName = 'div' - stopWrap.properties.className = imageWrapStopClass - }) - - node.value = convertHastToHtml(hast) - }) -} - -module.exports.extractInstructions = extractInstructions diff --git a/plugins/resize-image-plugin/index.test.js b/plugins/resize-image-plugin/index.test.js deleted file mode 100644 index 57a1c886c7..0000000000 --- a/plugins/resize-image-plugin/index.test.js +++ /dev/null @@ -1,40 +0,0 @@ -const { extractInstructions } = require('.') - -describe('extractInstructions', () => { - it('extracts the title if no instructions are found', () => { - expect(extractInstructions('I am a title')).toEqual({ - resize: null, - title: 'I am a title', - wrap: null - }) - }) - - it('extracts a resize instruction when it finds =NNN', () => { - expect(extractInstructions('=42 title')).toEqual({ - resize: 42, - title: 'title', - wrap: null - }) - }) - - it('extracts a wrap instruction when it finds :wrap-left or :wrap-right', () => { - expect(extractInstructions(':wrap-left title')).toEqual({ - resize: null, - title: 'title', - wrap: 'left' - }) - expect(extractInstructions(':wrap-right title')).toEqual({ - resize: null, - title: 'title', - wrap: 'right' - }) - }) - - it('extracts both wrap instructions and resize instructions', () => { - expect(extractInstructions('=200 :wrap-right title')).toEqual({ - resize: 200, - title: 'title', - wrap: 'right' - }) - }) -}) diff --git a/plugins/resize-image-plugin/package.json b/plugins/resize-image-plugin/package.json deleted file mode 100644 index 69ca34a37f..0000000000 --- a/plugins/resize-image-plugin/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "resize-image-plugin", - "version": "1.0.0", - "main": "index.js", - "author": "Franco", - "license": "Apache-2.0" -} diff --git a/plugins/utils/convertHast.js b/plugins/utils/convertHast.js deleted file mode 100644 index 353b6191fb..0000000000 --- a/plugins/utils/convertHast.js +++ /dev/null @@ -1,17 +0,0 @@ -const unified = require('unified') -const parse = require('rehype-parse') -const stringify = require('rehype-stringify') - -/** HAST - Hypertext Abstract Syntax Tree */ -function convertHtmlToHast(htmlString) { - return unified().use(parse, { fragment: true }).parse(htmlString) -} - -function convertHastToHtml(htmlAst) { - return unified().use(stringify).stringify(htmlAst) -} - -module.exports = { - convertHastToHtml, - convertHtmlToHast -} diff --git a/plugins/utils/makeFeedHtml.js b/plugins/utils/makeFeedHtml.js deleted file mode 100644 index 40fc6def98..0000000000 --- a/plugins/utils/makeFeedHtml.js +++ /dev/null @@ -1,53 +0,0 @@ -const { imageWrapperClass } = require('gatsby-remark-images/constants') -const unified = require('unified') -const { convertHastToHtml } = require('./convertHast.js') -const { select, selectAll } = require('hast-util-select') - -const rootToAbsolute = siteUrl => tree => { - selectAll('a', tree).forEach(node => { - if (node.properties.href.startsWith('/')) { - node.properties.href = siteUrl + node.properties.href - } - }) - selectAll('img', tree).forEach(node => { - if (node.properties.src.startsWith('/')) { - node.properties.src = siteUrl + node.properties.src - } - }) - return tree -} - -const unwrapImages = () => tree => { - selectAll(`.${imageWrapperClass}`, tree).forEach(node => { - // Set the fallback image as the wrapper's only child, and then - // give that image the wrapper's original style. - const fallbackImg = select('img', node) - node.children = [ - { - ...fallbackImg, - properties: { - ...fallbackImg.properties, - style: 'max-width: 100%; margin: auto;' - } - } - ] - }) - return tree -} - -function makeFeedHtml(htmlAst, siteUrl) { - // We add the rootToAbsolute processor before usage because it depends on siteUrl. - return convertHastToHtml( - unified() - /* - All images processed by Gatsby to be responsive are "unwrapped" into - their fallback 'img' nodes, as RSS doesn't work with the tricks that - true HTML does. - */ - .use(unwrapImages) - .use(rootToAbsolute, siteUrl) - .runSync(htmlAst) - ) -} - -module.exports = makeFeedHtml From 11a3080af1088e3b3b1c1afca1d735deb491459a Mon Sep 17 00:00:00 2001 From: rogermparent Date: Tue, 22 Mar 2022 15:34:54 -0400 Subject: [PATCH 02/37] Move and refactor stuff that was put into the theme --- .eslintrc.json | 1 - gatsby-browser.js | 5 - gatsby-config.js | 145 +- gatsby-node.js | 11 - gatsby-ssr.js | 3 - package.json | 145 +- postcss.config.js | 26 - src/components/Blog/FeedMeta/index.tsx | 18 +- src/components/Blog/Layout/index.tsx | 3 +- src/components/Blog/Post/index.tsx | 2 +- .../Blog/Search/SearchBox/styles.module.css | 4 +- .../Community/Block/styles.module.css | 2 +- .../Community/Meet/styles.module.css | 2 +- src/components/Community/Section/index.tsx | 2 +- .../Community/Section/styles.module.css | 4 +- src/components/Community/styles.module.css | 6 +- src/components/DocumentationLayout/index.tsx | 23 - .../DownloadButton/styles.module.css | 2 +- src/components/Features/styles.module.css | 4 +- src/components/Home/Diagram/styles.module.css | 6 +- .../LandingHero/GithubLine/styles.module.css | 8 +- .../Home/LandingHero/styles.module.css | 2 +- .../Home/LearnMore/styles.module.css | 2 +- .../CollapsibleText/styles.module.css | 2 +- src/components/Home/UseCases/Video/index.tsx | 1 - .../Home/UseCases/styles.module.css | 4 +- .../Home/WhatsNewModal/styles.module.css | 10 +- src/components/Page/DefaultSEO/index.tsx | 129 - src/components/Page/index.tsx | 58 - src/components/Page/styles.module.css | 4 - src/components/PageWrapper/index.js | 6 - src/components/PromoSection/styles.module.css | 10 +- src/components/PseudoButton/index.tsx | 32 - src/components/PseudoButton/styles.module.css | 48 - .../SubscribeSection/Form/styles.module.css | 4 +- src/components/Support/styles.module.css | 18 +- .../TwoRowsButton/styles.module.css | 2 +- .../components/AlertLandingLayout/index.tsx | 6 +- .../components/HamburgerMenu/index.tsx | 2 +- .../HamburgerMenu/styles.module.css | 4 +- .../components/LayoutFooter/index.tsx | 10 +- .../components/LayoutFooter/styles.module.css | 2 +- .../LayoutHeader/Nav/LinkItems/index.tsx | 10 +- .../Nav/LinkItems/styles.module.css | 2 +- .../LayoutHeader/Nav/Popup/index.tsx | 2 +- .../LayoutHeader/Nav/Popup/styles.module.css | 10 +- .../LayoutHeader/Nav/SocialIcons/index.tsx | 0 .../Nav/SocialIcons/styles.module.css | 0 .../components/LayoutHeader/Nav/index.tsx | 2 +- .../LayoutHeader/Nav/styles.module.css | 0 .../components/LayoutHeader/alert.tsx | 0 .../components/LayoutHeader/index.tsx | 7 +- .../components/LayoutHeader/styles.module.css | 0 .../components/MainLayout/index.tsx | 23 +- .../components/MainLayout/styles.module.css | 0 .../components/Page/base.css | 8 +- .../components/Page/fonts/brandon_bld.woff | Bin .../components/Page/fonts/brandon_bld.woff2 | Bin .../components/Page/fonts/brandon_bld_it.woff | Bin .../Page/fonts/brandon_bld_it.woff2 | Bin .../components/Page/fonts/brandon_blk.woff | Bin .../components/Page/fonts/brandon_blk.woff2 | Bin .../components/Page/fonts/brandon_blk_it.woff | Bin .../Page/fonts/brandon_blk_it.woff2 | Bin .../components/Page/fonts/brandon_light.woff | Bin .../components/Page/fonts/brandon_light.woff2 | Bin .../Page/fonts/brandon_light_it.woff | Bin .../Page/fonts/brandon_light_it.woff2 | Bin .../components/Page/fonts/brandon_med.woff | Bin .../components/Page/fonts/brandon_med.woff2 | Bin .../components/Page/fonts/brandon_med_it.woff | Bin .../Page/fonts/brandon_med_it.woff2 | Bin .../components/Page/fonts/brandon_reg.woff | Bin .../components/Page/fonts/brandon_reg.woff2 | Bin .../components/Page/fonts/brandon_reg_it.woff | Bin .../Page/fonts/brandon_reg_it.woff2 | Bin .../components/Page/fonts/brandon_thin.woff | Bin .../components/Page/fonts/brandon_thin.woff2 | Bin .../Page/fonts/brandon_thin_it.woff | Bin .../Page/fonts/brandon_thin_it.woff2 | Bin .../components/Page/fonts/fonts.css | 28 +- .../components/Page/getLayoutComponent.ts | 26 + src/gatsby/common.js | 17 +- src/gatsby/models.js | 2 - src/gatsby/models/blog/createPages.js | 2 +- .../blog/onCreateMarkdownContentNode.js | 4 +- src/gatsby/models/glossary/index.js | 73 - src/server/middleware/redirects/index.js | 2 +- tsconfig.json | 8 +- yarn.lock | 8270 +++++++++-------- 90 files changed, 4853 insertions(+), 4421 deletions(-) delete mode 100644 gatsby-browser.js delete mode 100644 postcss.config.js delete mode 100644 src/components/DocumentationLayout/index.tsx delete mode 100644 src/components/Page/DefaultSEO/index.tsx delete mode 100644 src/components/Page/index.tsx delete mode 100644 src/components/Page/styles.module.css delete mode 100644 src/components/PageWrapper/index.js delete mode 100644 src/components/PseudoButton/index.tsx delete mode 100644 src/components/PseudoButton/styles.module.css rename src/{ => gatsby-theme-iterative-docs}/components/AlertLandingLayout/index.tsx (75%) rename src/{ => gatsby-theme-iterative-docs}/components/HamburgerMenu/index.tsx (99%) rename src/{ => gatsby-theme-iterative-docs}/components/HamburgerMenu/styles.module.css (97%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutFooter/index.tsx (92%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutFooter/styles.module.css (97%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/Nav/LinkItems/index.tsx (88%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/Nav/LinkItems/styles.module.css (97%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/Nav/Popup/index.tsx (98%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/Nav/Popup/styles.module.css (83%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/Nav/SocialIcons/index.tsx (100%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/Nav/SocialIcons/styles.module.css (100%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/Nav/index.tsx (87%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/Nav/styles.module.css (100%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/alert.tsx (100%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/index.tsx (91%) rename src/{ => gatsby-theme-iterative-docs}/components/LayoutHeader/styles.module.css (100%) rename src/{ => gatsby-theme-iterative-docs}/components/MainLayout/index.tsx (75%) rename src/{ => gatsby-theme-iterative-docs}/components/MainLayout/styles.module.css (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/base.css (90%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_bld.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_bld.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_bld_it.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_bld_it.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_blk.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_blk.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_blk_it.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_blk_it.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_light.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_light.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_light_it.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_light_it.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_med.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_med.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_med_it.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_med_it.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_reg.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_reg.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_reg_it.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_reg_it.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_thin.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_thin.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_thin_it.woff (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/brandon_thin_it.woff2 (100%) rename src/{ => gatsby-theme-iterative-docs}/components/Page/fonts/fonts.css (55%) create mode 100644 src/gatsby-theme-iterative-docs/components/Page/getLayoutComponent.ts delete mode 100644 src/gatsby/models/glossary/index.js diff --git a/.eslintrc.json b/.eslintrc.json index c5ca87e148..bec84ec553 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -46,7 +46,6 @@ "files": [ "src/utils/shared/*.?(js|ts)", "src/gatsby/**/*.js", - "src/components/PageWrapper/index.js", "scripts/**/*.js", "config/**/*.js", "src/server/**/*.js", diff --git a/gatsby-browser.js b/gatsby-browser.js deleted file mode 100644 index 8b0fea8d96..0000000000 --- a/gatsby-browser.js +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-env node */ - -const PageWrapper = require('./src/components/PageWrapper').default - -exports.wrapPageElement = PageWrapper diff --git a/gatsby-config.js b/gatsby-config.js index 6ec56e8445..1f7f98766d 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -3,16 +3,10 @@ require('dotenv').config() const path = require('path') -require('./config/prismjs/dvc') -require('./config/prismjs/usage') -require('./config/prismjs/dvctable') +const makeFeedHtml = require('gatsby-theme-iterative-docs/plugins/utils/makeFeedHtml') -const customYoutubeTransformer = require('./config/gatsby-remark-embedder/custom-yt-embedder') const apiMiddleware = require('./src/server/middleware/api') const redirectsMiddleware = require('./src/server/middleware/redirects') -const makeFeedHtml = require('./plugins/utils/makeFeedHtml') -const { BLOG } = require('./src/consts') -const { linkIcon } = require('./static/icons') const title = 'Data Version Control · DVC' const description = @@ -27,28 +21,14 @@ const keywords = [ ] const plugins = [ - { - resolve: `gatsby-plugin-typescript`, - options: { - isTSX: true, - allExtensions: true - } - }, - 'gatsby-plugin-postcss', - 'gatsby-plugin-react-helmet', - 'gatsby-plugin-sitemap', 'gatsby-plugin-twitter', { resolve: 'gatsby-theme-iterative-docs', options: { - remark: false - } - }, - { - resolve: 'gatsby-source-filesystem', - options: { - name: 'content', - path: path.join(__dirname, 'content') + remark: false, + cssBase: require.resolve( + './src/gatsby-theme-iterative-docs/components/Page/base.css' + ) } }, { @@ -58,99 +38,7 @@ const plugins = [ path: path.join(__dirname, 'static', 'uploads') } }, - { - resolve: 'gatsby-source-filesystem', - options: { - name: 'img', - path: path.join(__dirname, 'static') - } - }, - 'gatsby-plugin-image', 'community-page', - { - resolve: 'gatsby-transformer-remark', - options: { - plugins: [ - { - resolve: 'gatsby-remark-embedder', - options: { - customTransformers: [customYoutubeTransformer] - } - }, - 'gatsby-remark-dvc-linker', - { - resolve: 'gatsby-remark-args-linker', - options: { - icon: linkIcon, - // Pathname can also be array of paths. eg: ['docs/command-reference;', 'docs/api'] - pathname: 'docs/command-reference' - } - }, - { - resolve: 'gatsby-remark-prismjs', - options: { - noInlineHighlight: true, - languageExtensions: [ - { - language: 'text', - definition: {} - } - ] - } - }, - { - resolve: 'gatsby-remark-smartypants', - options: { - quotes: false - } - }, - { - resolve: 'gatsby-remark-embed-gist', - options: { - includeDefaultCss: true - } - }, - 'gatsby-remark-relative-images', - 'gatsby-remark-copy-linked-files', - 'gatsby-remark-external-links', - { - resolve: 'gatsby-remark-autolink-headers', - options: { - enableCustomId: true, - isIconAfterHeader: true, - icon: linkIcon - } - }, - { - resolve: 'gatsby-remark-images', - options: { - maxWidth: BLOG.imageMaxWidth, - withWebp: true, - quality: 90, - loading: 'auto' - } - }, - 'gatsby-remark-responsive-iframe', - 'resize-image-plugin', - 'external-link-plugin' - ] - } - }, - { - resolve: 'gatsby-plugin-svgr', - options: { - ref: true - } - }, - 'gatsby-transformer-sharp', - { - resolve: 'gatsby-plugin-sharp', - options: { - defaults: { - placeholder: 'blurred' - } - } - }, { resolve: 'gatsby-plugin-catch-links', options: { @@ -286,29 +174,6 @@ const plugins = [ } ` } - }, - { - resolve: 'gatsby-plugin-sentry', - options: { - dsn: process.env.SENTRY_DSN, - environment: process.env.NODE_ENV, - release: process.env.SOURCE_VERSION, - enabled: process.env.NODE_ENV === 'production', - ignoreErrors: [ - /* When we deploy new version we delete assets which were generated for - the previous deployed version, but users can have opened old version in - their browsers. If they hover some link on the page Gatsby.js will try - fetch old chunks and will get ChunkLoadError, but then will load static - page from the new deployed version and all will be ok. So we can just - ignore these type of errors */ - 'ChunkLoadError' - ], - /* There are some common urls which recomment to ignore. It's even - mentioned in the official documentation: https://docs.sentry.io/platforms/javascript/#decluttering-sentry - In our case we just ignore all errors from the browser's extensions, - because we can't influence on then somehow. */ - blacklistUrls: [/extensions\//i, /^chrome:\/\//i] - } } ] diff --git a/gatsby-node.js b/gatsby-node.js index 7001ba73b7..913a6234c5 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,5 +1,4 @@ require('dotenv').config() -const path = require('path') global.__basedir = __dirname const { setPageContext } = require('./src/gatsby/common') @@ -41,14 +40,4 @@ exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => { } actions.replaceWebpackConfig(config) } - actions.setWebpackConfig({ - resolve: { - alias: { - 'gatsby-theme-iterative-docs': path.resolve( - 'plugins', - 'gatsby-theme-iterative-docs' - ) - } - } - }) } diff --git a/gatsby-ssr.js b/gatsby-ssr.js index eeec39a1d5..d1bd2e3870 100644 --- a/gatsby-ssr.js +++ b/gatsby-ssr.js @@ -1,8 +1,6 @@ /* eslint-env node */ const React = require('react') -const PageWrapper = require('./src/components/PageWrapper').default - const onRenderBody = ({ setHeadComponents }) => { return setHeadComponents([ - - ) -} - -export default DefaultSEO diff --git a/src/components/Page/index.tsx b/src/components/Page/index.tsx deleted file mode 100644 index 8adcef304c..0000000000 --- a/src/components/Page/index.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import React from 'react' - -import MainLayout from '../MainLayout' -import DefaultSEO from './DefaultSEO' -import DocumentationLayout from '../DocumentationLayout' -import AlertLandingLayout from '../AlertLandingLayout' -import Layout from '../Blog/Layout' - -import { useRedirects, useAnchorNavigation, useSmoothScroll } from './utils' - -import 'reset-css' -import './base.css' -import './fonts/fonts.css' - -export interface IPageProps { - location: { - pathname: string - } - pageContext: { - is404: boolean - isDocs: boolean - isBlog: boolean - isAlertLanding: boolean - pageInfo?: { - currentPage: number - nextPage?: string - } - } - children: React.ReactNode - enableSmoothScroll: boolean -} - -const Page: React.FC = props => { - let LayoutComponent = MainLayout - - useRedirects() - useAnchorNavigation() - useSmoothScroll(props.enableSmoothScroll) - - if (!props.pageContext.is404) { - if (props.pageContext.isDocs) { - LayoutComponent = DocumentationLayout - } else if (props.pageContext.isBlog) { - LayoutComponent = Layout - } else if (props.pageContext.isAlertLanding) { - LayoutComponent = AlertLandingLayout - } - } - - return ( - <> - - - - ) -} - -export default Page diff --git a/src/components/Page/styles.module.css b/src/components/Page/styles.module.css deleted file mode 100644 index 412274331f..0000000000 --- a/src/components/Page/styles.module.css +++ /dev/null @@ -1,4 +0,0 @@ -.smoothScrolling { - scroll-behavior: smooth; - will-change: scroll-position; -} diff --git a/src/components/PageWrapper/index.js b/src/components/PageWrapper/index.js deleted file mode 100644 index cf254f5cf6..0000000000 --- a/src/components/PageWrapper/index.js +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react' -import Page from '../Page' - -export default function PageWrapper({ element, props }) { - return {element} -} diff --git a/src/components/PromoSection/styles.module.css b/src/components/PromoSection/styles.module.css index 13ee10356c..9ff19a97d4 100644 --- a/src/components/PromoSection/styles.module.css +++ b/src/components/PromoSection/styles.module.css @@ -34,7 +34,7 @@ } .title { - font-family: var(--font-brandon); + font-family: var(--font-base); max-width: 438px; min-height: 44px; margin: 0 auto; @@ -65,14 +65,14 @@ padding: 0 21px; border-radius: 4px; border: solid 2px rgb(255 255 255 / 30%); - font-family: var(--font-brandon); + font-family: var(--font-base); font-size: 20px; font-weight: 500; line-height: 0.9; text-decoration: none; text-align: left; color: #fff; - background: var(--color-purple) url("/img/arrow_right_white.svg") right center + background: var(--color-purple) url('/img/arrow_right_white.svg') right center no-repeat; background-position-x: 147px; transition: 0.2s background-color ease-out; @@ -97,7 +97,7 @@ border-radius: 4px; background-color: #fff; box-shadow: 0 2px 4px 0 rgb(0 0 0 / 21%); - background-image: url("/img/arrow_right_dark.svg"); + background-image: url('/img/arrow_right_dark.svg'); transition: 0.2s background-color ease-out; &:hover { @@ -105,7 +105,7 @@ } &:focus { - background: var(--color-orange) url("/img/arrow_right_white.svg") right + background: var(--color-orange) url('/img/arrow_right_white.svg') right center no-repeat; background-position-x: 147px; box-shadow: 0 2px 4px 0 rgb(0 0 0 / 21%); diff --git a/src/components/PseudoButton/index.tsx b/src/components/PseudoButton/index.tsx deleted file mode 100644 index b24f580bdd..0000000000 --- a/src/components/PseudoButton/index.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import cn from 'classnames' -import React from 'react' - -import Link, { - ILinkProps -} from 'gatsby-theme-iterative-docs/src/components/Link' - -import * as styles from './styles.module.css' - -type IPseudoButtonProps = { - children: React.ReactNode - className?: string - type?: 'primary' | 'secondary' - size?: 'small' | 'big' | 'none' -} & ILinkProps - -const PseudoButton: React.FC = ({ - children, - className, - type = 'primary', - size = 'small', - ...restProps -}) => ( - - {children} - -) - -export default PseudoButton diff --git a/src/components/PseudoButton/styles.module.css b/src/components/PseudoButton/styles.module.css deleted file mode 100644 index 1d94291a01..0000000000 --- a/src/components/PseudoButton/styles.module.css +++ /dev/null @@ -1,48 +0,0 @@ -.button { - @mixin active; - - box-sizing: border-box; - display: inline-flex; - justify-content: center; - align-items: center; - border: 2px solid; - padding: 1px 19px 2px; - text-decoration: none; - font-weight: 700; - transition: 0.2s background-color ease-out; - - &.small { - @mixin button-small; - - height: 38px; - border-radius: 4px; - } - - &.big { - @mixin button-big; - - height: 60px; - border-radius: 8px; - } - - &.primary { - border-color: var(--color-azure); - color: #fff; - background-color: var(--color-azure); - - &:hover { - background-color: #13a3bd; - } - } - - &.secondary { - border-color: var(--color-gray-opaque); - color: var(--color-gray); - background-color: transparent; - - &:hover { - border-color: var(--color-gray); - color: var(--color-gray-hover); - } - } -} diff --git a/src/components/SubscribeSection/Form/styles.module.css b/src/components/SubscribeSection/Form/styles.module.css index 74e787e40b..021b71ba20 100644 --- a/src/components/SubscribeSection/Form/styles.module.css +++ b/src/components/SubscribeSection/Form/styles.module.css @@ -11,7 +11,7 @@ } .input { - font-family: var(--font-brandon); + font-family: var(--font-base); display: flex; flex: 1; padding: 16px; @@ -30,7 +30,7 @@ } .button { - font-family: var(--font-brandon); + font-family: var(--font-base); width: 115px; border: none; border-radius: 0 8px 8px 0; diff --git a/src/components/Support/styles.module.css b/src/components/Support/styles.module.css index 8fb90e3fd4..fd957b7b14 100644 --- a/src/components/Support/styles.module.css +++ b/src/components/Support/styles.module.css @@ -7,7 +7,7 @@ .heading { max-width: 610px; margin: 0 auto; - font-family: var(--font-brandon); + font-family: var(--font-base); font-size: 40px; font-weight: 500; line-height: 1.4; @@ -70,11 +70,11 @@ } &.chat .featureIcon::after { - mask-image: url("/img/support/chat.svg"); + mask-image: url('/img/support/chat.svg'); } &.email .featureIcon::after { - mask-image: url("/img/support/email.svg"); + mask-image: url('/img/support/email.svg'); } &.bugs { @@ -83,7 +83,7 @@ &::after { background-color: var(--color-azure); - mask-image: url("/img/support/bug.svg"); + mask-image: url('/img/support/bug.svg'); } } @@ -108,7 +108,7 @@ &::after { background-color: var(--color-orange-bright); - mask-image: url("/img/support/forum.svg"); + mask-image: url('/img/support/forum.svg'); } } @@ -141,7 +141,7 @@ border-radius: 50%; &::after { - content: " "; + content: ' '; display: block; width: 50px; height: 50px; @@ -156,7 +156,7 @@ min-height: 28px; margin-top: 10px; margin-bottom: 10px; - font-family: var(--font-brandon); + font-family: var(--font-base); font-size: 22px; font-weight: 500; color: var(--color-gray-hover); @@ -184,7 +184,7 @@ padding: 0 20px; border: 2px solid; border-radius: 4px; - font-family: var(--font-brandon); + font-family: var(--font-base); font-weight: 500; font-size: 18px; line-height: 38px; @@ -208,7 +208,7 @@ width: 50px; height: 50px; cursor: pointer; - mask-image: url("/img/support/discord.svg"); + mask-image: url('/img/support/discord.svg'); mask-repeat: no-repeat; mask-position: center; background-color: #b88eeb; diff --git a/src/components/TwoRowsButton/styles.module.css b/src/components/TwoRowsButton/styles.module.css index 3184a2ce50..d1dc20df99 100644 --- a/src/components/TwoRowsButton/styles.module.css +++ b/src/components/TwoRowsButton/styles.module.css @@ -70,7 +70,7 @@ display: flex; flex-direction: column; align-items: flex-start; - font-family: var(--font-brandon); + font-family: var(--font-base); } .title { diff --git a/src/components/AlertLandingLayout/index.tsx b/src/gatsby-theme-iterative-docs/components/AlertLandingLayout/index.tsx similarity index 75% rename from src/components/AlertLandingLayout/index.tsx rename to src/gatsby-theme-iterative-docs/components/AlertLandingLayout/index.tsx index c043e9ad15..2e76b0e956 100644 --- a/src/components/AlertLandingLayout/index.tsx +++ b/src/gatsby-theme-iterative-docs/components/AlertLandingLayout/index.tsx @@ -1,5 +1,9 @@ import React from 'react' -import MainLayout, { LayoutComponent, LayoutModifiers } from '../MainLayout' +import MainLayout from '../MainLayout' +import { + LayoutComponent, + LayoutModifiers +} from 'gatsby-theme-iterative-docs/src/components/MainLayout' const alertComponentModifiers: LayoutModifiers[] = [ LayoutModifiers.Collapsed, diff --git a/src/components/HamburgerMenu/index.tsx b/src/gatsby-theme-iterative-docs/components/HamburgerMenu/index.tsx similarity index 99% rename from src/components/HamburgerMenu/index.tsx rename to src/gatsby-theme-iterative-docs/components/HamburgerMenu/index.tsx index 8311d0756a..39521feec7 100644 --- a/src/components/HamburgerMenu/index.tsx +++ b/src/gatsby-theme-iterative-docs/components/HamburgerMenu/index.tsx @@ -6,7 +6,7 @@ import Link from 'gatsby-theme-iterative-docs/src/components/Link' import { logEvent } from 'gatsby-theme-iterative-docs/src/utils/front/plausible' import { getFirstPage } from 'gatsby-theme-iterative-docs/src/utils/shared/sidebar' -import { ReactComponent as LogoSVG } from '../../../static/img/logo-white.svg' +import { ReactComponent as LogoSVG } from '../../../../static/img/logo-white.svg' import { ReactComponent as TwitterIcon } from 'gatsby-theme-iterative-docs/src/components/SocialIcon/twitter.svg' import { ReactComponent as GithubIcon } from 'gatsby-theme-iterative-docs/src/components/SocialIcon/github.svg' diff --git a/src/components/HamburgerMenu/styles.module.css b/src/gatsby-theme-iterative-docs/components/HamburgerMenu/styles.module.css similarity index 97% rename from src/components/HamburgerMenu/styles.module.css rename to src/gatsby-theme-iterative-docs/components/HamburgerMenu/styles.module.css index f53d1e43ec..9ea59bd637 100644 --- a/src/components/HamburgerMenu/styles.module.css +++ b/src/gatsby-theme-iterative-docs/components/HamburgerMenu/styles.module.css @@ -135,7 +135,7 @@ .sectionHeading { display: block; padding: 15px 0; - font-family: var(--font-brandon); + font-family: var(--font-base); font-weight: 400; font-size: 13px; line-height: 20px; @@ -213,7 +213,7 @@ a.sectionHeading { height: 38px; border-radius: 4px; background-color: #fff; - font-family: var(--font-brandon); + font-family: var(--font-base); font-size: 16px; line-height: 38px; text-align: center; diff --git a/src/components/LayoutFooter/index.tsx b/src/gatsby-theme-iterative-docs/components/LayoutFooter/index.tsx similarity index 92% rename from src/components/LayoutFooter/index.tsx rename to src/gatsby-theme-iterative-docs/components/LayoutFooter/index.tsx index 5d9f7fe3e4..ae87b3df5f 100644 --- a/src/components/LayoutFooter/index.tsx +++ b/src/gatsby-theme-iterative-docs/components/LayoutFooter/index.tsx @@ -9,14 +9,14 @@ import SocialIcon, { import ShowOnly from 'gatsby-theme-iterative-docs/src/components/ShowOnly' import { getFirstPage } from 'gatsby-theme-iterative-docs/src/utils/shared/sidebar' -import { ReactComponent as LogoSVG } from '../../../static/img/dvc_icon-color--square_vector.svg' +import { ReactComponent as LogoSVG } from '../../../../static/img/dvc_icon-color--square_vector.svg' import { ReactComponent as GithubSVG } from 'gatsby-theme-iterative-docs/src/components/SocialIcon/github.svg' import { ReactComponent as TwitterSVG } from 'gatsby-theme-iterative-docs/src/components/SocialIcon/twitter.svg' import { ReactComponent as DiscordSVG } from 'gatsby-theme-iterative-docs/src/components/SocialIcon/discord.svg' -import { ReactComponent as CmlSVG } from '../../../static/img/cml_icon-color--square_vector.svg' -import { ReactComponent as StudioSVG } from '../../../static/img/studio_icon-color--square_vector.svg' -import { ReactComponent as IterativeSVG } from '../../../static/img/iterative_icon-color--square_vector.svg' -import { ReactComponent as MlemSVG } from '../../../static/img/mlem-icon.svg' +import { ReactComponent as CmlSVG } from '../../../../static/img/cml_icon-color--square_vector.svg' +import { ReactComponent as StudioSVG } from '../../../../static/img/studio_icon-color--square_vector.svg' +import { ReactComponent as IterativeSVG } from '../../../../static/img/iterative_icon-color--square_vector.svg' +import { ReactComponent as MlemSVG } from '../../../../static/img/mlem-icon.svg' import * as styles from './styles.module.css' diff --git a/src/components/LayoutFooter/styles.module.css b/src/gatsby-theme-iterative-docs/components/LayoutFooter/styles.module.css similarity index 97% rename from src/components/LayoutFooter/styles.module.css rename to src/gatsby-theme-iterative-docs/components/LayoutFooter/styles.module.css index 3adc0bbff9..69be223f0c 100644 --- a/src/components/LayoutFooter/styles.module.css +++ b/src/gatsby-theme-iterative-docs/components/LayoutFooter/styles.module.css @@ -4,7 +4,7 @@ } .div { - background-image: url("../../../static/img/cml_icon-color--square_vector.svg"); + background-image: url('../../../../static/img/cml_icon-color--square_vector.svg'); } .container { diff --git a/src/components/LayoutHeader/Nav/LinkItems/index.tsx b/src/gatsby-theme-iterative-docs/components/LayoutHeader/Nav/LinkItems/index.tsx similarity index 88% rename from src/components/LayoutHeader/Nav/LinkItems/index.tsx rename to src/gatsby-theme-iterative-docs/components/LayoutHeader/Nav/LinkItems/index.tsx index 27ed566253..360405eef5 100644 --- a/src/components/LayoutHeader/Nav/LinkItems/index.tsx +++ b/src/gatsby-theme-iterative-docs/components/LayoutHeader/Nav/LinkItems/index.tsx @@ -9,18 +9,17 @@ import { IPopupProps } from '../Popup' -import { ReactComponent as ArrowUpSVG } from '../../../../../static/img/arrow-up-icon.svg' -import { ReactComponent as ArrowDownSVG } from '../../../../../static/img/arrow-down-icon.svg' +import { ReactComponent as ArrowUpSVG } from '../../../../../../static/img/arrow-up-icon.svg' +import { ReactComponent as ArrowDownSVG } from '../../../../../../static/img/arrow-down-icon.svg' import { logEvent } from 'gatsby-theme-iterative-docs/src/utils/front/plausible' import { getFirstPage } from 'gatsby-theme-iterative-docs/src/utils/shared/sidebar' -import usePopup, { IUsePopupReturn } from '../../../../gatsby/hooks/usePopup' +import usePopup, { IUsePopupReturn } from '../../../../../gatsby/hooks/usePopup' const docsPage = getFirstPage() import * as styles from './styles.module.css' -import { ReactComponent as EllipsisIcon } from '../../../../../static/img/ellipsis.svg' -import onSelectKey from '../../../../utils/onSelectKey' +import { ReactComponent as EllipsisIcon } from '../../../../../../static/img/ellipsis.svg' type PopupName = 'communityPopup' | 'otherToolsPopup' | 'otherPopup' @@ -118,7 +117,6 @@ const LinkItems: React.FC = () => { diff --git a/src/@dvcorg/gatsby-theme-iterative/components/MainLayout/index.tsx b/src/@dvcorg/gatsby-theme-iterative/components/MainLayout/index.tsx index 01bca0c964..5690584eeb 100644 --- a/src/@dvcorg/gatsby-theme-iterative/components/MainLayout/index.tsx +++ b/src/@dvcorg/gatsby-theme-iterative/components/MainLayout/index.tsx @@ -11,10 +11,7 @@ import * as styles from './styles.module.css' import { logEvent } from '@dvcorg/gatsby-theme-iterative/src/utils/front/plausible' import { useLocation } from '@reach/router' -export { - LayoutComponent, - LayoutModifiers -} from '@dvcorg/gatsby-theme-iterative/src/components/MainLayout' +export * from '@dvcorg/gatsby-theme-iterative/src/components/MainLayout' const MainLayout: LayoutComponent = ({ className, diff --git a/src/@dvcorg/gatsby-theme-iterative/components/data/menu.ts b/src/@dvcorg/gatsby-theme-iterative/components/data/menu.ts index f8b532dd9e..52bafda7f0 100644 --- a/src/@dvcorg/gatsby-theme-iterative/components/data/menu.ts +++ b/src/@dvcorg/gatsby-theme-iterative/components/data/menu.ts @@ -78,7 +78,8 @@ const menuData: IMenuData = { ariaLabel: 'Show options', popupName: 'otherPopup', Popup: OtherPopup, - className: styles.other + className: styles.other, + hideDropdown: true } ], community: [ diff --git a/src/@dvcorg/gatsby-theme-iterative/components/data/styles.module.css b/src/@dvcorg/gatsby-theme-iterative/components/data/styles.module.css index d491486f56..2610bd9e57 100644 --- a/src/@dvcorg/gatsby-theme-iterative/components/data/styles.module.css +++ b/src/@dvcorg/gatsby-theme-iterative/components/data/styles.module.css @@ -1,15 +1,21 @@ .cmlIcon { - background-image: url("../../../../../static/img/cml_icon-color--square_vector.svg"); + background-image: url('../../../../../static/img/cml_icon-color--square_vector.svg'); } .dvcIcon { - background-image: url("../../../../../static/img/dvc_icon-color--square_vector.svg"); + background-image: url('../../../../../static/img/dvc_icon-color--square_vector.svg'); } .studioIcon { - background-image: url("../../../../../static/img/studio_icon-color--square_vector.svg"); + background-image: url('../../../../../static/img/studio_icon-color--square_vector.svg'); } .mlemIcon { - background-image: url("../../../../../static/img/mlem-icon.svg"); + background-image: url('../../../../../static/img/mlem-icon.svg'); +} + +.other { + font-weight: 600; + letter-spacing: 2px; + font-size: 20px; } From 59ef9a96dea21b91170e3d14df7e185436b7f6df Mon Sep 17 00:00:00 2001 From: Thomas Kunwar Date: Wed, 8 Jun 2022 23:33:43 +0545 Subject: [PATCH 37/37] upgraded theme pacakge --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cca6365524..ca20e714a2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "node": ">=14.x <=16.x" }, "dependencies": { - "@dvcorg/gatsby-theme-iterative": "^0.1.6", + "@dvcorg/gatsby-theme-iterative": "^0.1.7", "@hapi/wreck": "^18.0.0", "@octokit/graphql": "^4.8.0", "@reach/portal": "^0.17.0", diff --git a/yarn.lock b/yarn.lock index ff0b6d53c0..a4c53fd67b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2409,10 +2409,10 @@ resolved "https://registry.npmjs.org/@csstools/convert-colors/-/convert-colors-1.4.0.tgz" integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw== -"@dvcorg/gatsby-theme-iterative@^0.1.6": - version "0.1.6" - resolved "https://registry.yarnpkg.com/@dvcorg/gatsby-theme-iterative/-/gatsby-theme-iterative-0.1.6.tgz#dbd84f25075cae260050205f99b22481c1091508" - integrity sha512-Dx5oBW1Fv9sZPtR/zqpsBBnqf/PLW4b0R7Otm/7fyo2LB/iOLvt1mfJengKOgpMnQNCDLvxvIQwNwuVtIDIwTw== +"@dvcorg/gatsby-theme-iterative@^0.1.7": + version "0.1.7" + resolved "https://registry.yarnpkg.com/@dvcorg/gatsby-theme-iterative/-/gatsby-theme-iterative-0.1.7.tgz#b34e9e384a2d47e37162741d5d3ccc025e50dd24" + integrity sha512-qSCZs/9UUhQeIMlXIcJqxNpbp6ol7D99eAc04Fm7maVryq3mtV0epVgn9ZCGWkbV9sst7nZ4Frd02lZH2Ah42Q== dependencies: "@reach/portal" "^0.17.0" "@reach/router" "^1.3.4"