diff --git a/.dagger/env/docs/.gitignore b/.dagger/env/docs/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/.dagger/env/docs/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/.dagger/env/docs/plan/main.cue b/.dagger/env/docs/plan/main.cue new file mode 100644 index 00000000..e8f07048 --- /dev/null +++ b/.dagger/env/docs/plan/main.cue @@ -0,0 +1,23 @@ +package main + +import ( + "dagger.io/dagger" + "dagger.io/js/yarn" + "dagger.io/netlify" +) + +// dagger repository +repository: dagger.#Artifact @dagger(input) + +// Build the docs website +docs: yarn.#Package & { + source: repository + cwd: "tools/daggosaurus/" + buildDir: "tools/daggosaurus/build" +} + +// Deploy the docs website +site: netlify.#Site & { + name: string | *"docs-dagger-io" @dagger(input) + contents: docs.build +} diff --git a/.dagger/env/docs/values.yaml b/.dagger/env/docs/values.yaml new file mode 100644 index 00000000..c7d9acdd --- /dev/null +++ b/.dagger/env/docs/values.yaml @@ -0,0 +1,33 @@ +name: docs +inputs: + repository: + dir: + path: . + exclude: + - '**/node_modules' + - cmd/dagger/dagger + - cmd/dagger/dagger-debug + site.account.name: + text: blocklayer + site.account.token: + secret: ENC[AES256_GCM,data:jPJ8N6cAmtYnQh2SyhM9bQGfkhz777S4fyPDm2YhujwgXH6EogN2Uyw6Ew==,iv:gDchoJYLdQ8IPxrUUIsQ9s2f12JOhh7p573DwOIV2zE=,tag:okatHyjVGPGNOt+aw4iUHg==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBaZVVuYThsYk9YcWhYb0g4 + TDhZQ21YN0FCRExKV2tqbVVUNTg5MWRUVUJzCndjc28yVUZEK3ZoQzVDQkk4emZQ + WGx2bUxSZlBENXlibzQ1MVkvc2I2MVkKLS0tIFJKS0ZENFhuVmdUM2h1a2xrK01a + ejRKQXNFZzBTbUxpc05acnkxQ2U2UkEKX1byNj64xOiRGAJ9lwh55d/mlasI3H6H + b+o3HbXSbV0G0UwQxEOisntR6o27ry/l12ai/sOQ4f9MXm6FRw2XTg== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-02T22:14:46Z" + mac: ENC[AES256_GCM,data:x/Up/GCLTwIWSbyxvy3S79j4gbKRRYnDguvgPJFAii2PS6rjSU7KHtwM9WbUqQtd+NDbe1eWjdmAC4jPwVsa9OY7s+heR3597OpTh0pHcOgTrc4fTVN9IVHwehlg4hJU00iL1oiiHfeCD5dMUGeIRyqRqoAyMJrPdC9IDwjnp6E=,iv:IUbrkPQqLC/wnfKZMnOK9jKSc+xDXpeJwKLXuioifyE=,tag:2l+FhV3k5WvhQyvvf37Hjw==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 6f1ba43e..dcd3541d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,8 +2,6 @@ name: Docs on: push: - branches: - - main tags: - v* paths: @@ -15,75 +13,11 @@ on: jobs: deploy: runs-on: ubuntu-latest - env: - AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: "us-east-1" - steps: - - name: Set Version - id: vars - run: | - tag=${GITHUB_REF#refs/*/} - [ "$tag" = "main" ] && echo ::set-output name=tag::devel || echo ::set-output name=tag::$tag - - # fetch-depth: '0' enables listing all tags for version selector - uses: actions/checkout@v2 with: fetch-depth: "0" - - ################################################################# - # BUILD SITE - ################################################################# - - # Install Node - - uses: actions/setup-node@v2 + - uses: dagger/dagger-action@v1 with: - node-version: "14" - - run: yarn --cwd ./tools/gendocs - - name: Build Site - run: yarn --cwd ./tools/gendocs build --prefix-paths - env: - VERSION: ${{steps.vars.outputs.tag}} - - ################################################################# - # DEPLOY TO S3 - ################################################################# - - # deploy the site in the right foder ( tag or devel) - - name: S3 Sync - uses: ItsKarma/aws-cli@v1.70.0 - with: - args: s3 sync --delete ./tools/gendocs/public/ s3://docs.dagger.io/${{steps.vars.outputs.tag}}/ - - # list All Tags in json file for version selector - # upload to /tags.json - - name: Create tags.json - run: echo "[" {\"tag\"':' \"$(git tag -l "v*" | tr '\n' '|' | sed -e 's/|/"}, {\"tag\"':' "/g')devel\"} "]" > tags.json - - name: Copy tags.json - uses: ItsKarma/aws-cli@v1.70.0 - with: - args: s3 cp ./tags.json s3://docs.dagger.io/ - - # landing alway on latest tag - # use S3 Rediret objet - # upload to /docs/index.html - - name: Create index.html - run: | - cat < index.html - - - - - - - Nothing to see here; see the - latest version of the docs. - - - EOF - - name: Copy index.html - if: ${{ steps.vars.outputs.tag != 'devel' }} - uses: ItsKarma/aws-cli@v1.70.0 - with: - args: s3 cp --cache-control max-age=0 ./index.html s3://docs.dagger.io/ + age-key: ${{ secrets.DAGGER_AGE_KEY }} + args: up -e docs diff --git a/environment/pipeline.go b/environment/pipeline.go index a94de13f..08c4f74b 100644 --- a/environment/pipeline.go +++ b/environment/pipeline.go @@ -213,6 +213,8 @@ func (p *Pipeline) doOp(ctx context.Context, op *compiler.Value, st llb.State) ( return p.Local(ctx, op, st) case "load": return p.Load(ctx, op, st) + case "workdir": + return p.Workdir(ctx, op, st) case "subdir": return p.Subdir(ctx, op, st) case "docker-build": @@ -232,6 +234,14 @@ func (p *Pipeline) vertexNamef(format string, a ...interface{}) string { return prefix + " " + name } +func (p *Pipeline) Workdir(ctx context.Context, op *compiler.Value, st llb.State) (llb.State, error) { + path, err := op.Lookup("path").String() + if err != nil { + return st, err + } + return st.Dir(path), nil +} + func (p *Pipeline) Subdir(ctx context.Context, op *compiler.Value, st llb.State) (llb.State, error) { // FIXME: this could be more optimized by carrying subdir path as metadata, // and using it in copy, load or mount. diff --git a/stdlib/aws/s3/s3.cue b/stdlib/aws/s3/s3.cue index 5207066a..99e8a20e 100644 --- a/stdlib/aws/s3/s3.cue +++ b/stdlib/aws/s3/s3.cue @@ -25,7 +25,7 @@ import ( contentType: string | *"" @dagger(input) // Always write the object to S3 - always?: bool @dagger(input) + always: bool | *true @dagger(input) // URL of the uploaded S3 object url: { @@ -90,3 +90,80 @@ import ( ] } } + +// S3 Sync +#Sync: { + // AWS Config + config: aws.#Config + + // Source Artifact to upload to S3 + source: dagger.#Artifact @dagger(input) + + // Target S3 URL (eg. s3:////) + target: string @dagger(input) + + // Files that exist in the destination but not in the + // source are deleted during sync. + delete: *false | bool @dagger(input) + + // Object content type + contentType: string | *"" @dagger(input) + + // Always write the object to S3 + always: bool | *true @dagger(input) + + // URL of the uploaded S3 object + url: { + @dagger(output) + string + + #up: [ + op.#Load & { + from: aws.#CLI & { + "config": config + } + }, + + op.#Exec & { + if always != _|_ { + "always": always + } + env: { + TARGET: target + OPT_CONTENT_TYPE: contentType + if delete { + OPT_DELETE: "1" + } + } + + mount: "/source": from: source + + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "-c", + #""" + opts=() + if [ -d /source ]; then + op=sync + fi + [ -n "$OPT_CONTENT_TYPE" ] && opts+="--content-type $OPT_CONTENT_TYPE" + [ -n "$OPT_DELETE" ] && opts+="--delete" + aws s3 sync ${opts[@]} /source "$TARGET" + echo -n "$TARGET" \ + | sed -E 's=^s3://([^/]*)/=https://\1.s3.amazonaws.com/=' \ + > /url + """#, + ] + }, + + op.#Export & { + source: "/url" + format: "string" + }, + ] + } +} diff --git a/stdlib/dagger/op/op.cue b/stdlib/dagger/op/op.cue index 3961e7e2..aeb94423 100644 --- a/stdlib/dagger/op/op.cue +++ b/stdlib/dagger/op/op.cue @@ -40,6 +40,11 @@ package op dir: string } +#Workdir: { + do: "workdir" + path: string +} + #Exec: { do: "exec" args: [...string] diff --git a/stdlib/dagger/op/op_fullop.cue b/stdlib/dagger/op/op_fullop.cue index fc763832..3fa35920 100644 --- a/stdlib/dagger/op/op_fullop.cue +++ b/stdlib/dagger/op/op_fullop.cue @@ -12,6 +12,7 @@ package op #Copy | #Load | #Subdir | + #Workdir | #WriteFile | #Mkdir | #DockerBuild) & {do: string} diff --git a/stdlib/git/git.cue b/stdlib/git/git.cue index 35713db0..aa07e4eb 100644 --- a/stdlib/git/git.cue +++ b/stdlib/git/git.cue @@ -1,7 +1,9 @@ package git import ( + "dagger.io/dagger" "dagger.io/dagger/op" + "dagger.io/alpine" ) // A git repository @@ -23,3 +25,82 @@ import ( }, ] } + +// Get the name of the current checked out branch or tag +#CurrentBranch: { + repository: dagger.#Artifact @dagger(input) + name: { + string + @dagger(output) + + #up: [ + op.#Load & { + from: alpine.#Image & { + package: bash: "=~5.1" + package: git: "=~2.30" + } + }, + + op.#Exec & { + mount: "/repository": from: repository + dir: "/repository" + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "-c", + #""" + printf "$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" > /name.txt + """#, + ] + }, + + op.#Export & { + source: "/name.txt" + format: "string" + }, + ] + } +} + +// List tags of a repository +#Tags: { + repository: dagger.#Artifact @dagger(input) + tags: { + [...string] + @dagger(output) + + #up: [ + op.#Load & { + from: alpine.#Image & { + package: bash: "=~5.1" + package: jq: "=~1.6" + package: git: "=~2.30" + } + }, + + op.#Exec & { + mount: "/repository": from: repository + dir: "/repository" + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "-c", + #""" + git tag -l | jq --raw-input --slurp 'split("\n") | map(select(. != ""))' > /tags.json + """#, + ] + }, + + op.#Export & { + source: "/tags.json" + format: "json" + }, + ] + } +} diff --git a/stdlib/js/yarn/yarn.cue b/stdlib/js/yarn/yarn.cue index 81b9bbed..cefb2f29 100644 --- a/stdlib/js/yarn/yarn.cue +++ b/stdlib/js/yarn/yarn.cue @@ -15,6 +15,14 @@ import ( // Application source code source: dagger.#Artifact @dagger(input) + // Extra alpine packages to install + package: { + [string]: true | false | string @dagger(input) + } + + // working directory to use + cwd: *"." | string @dagger(input) + // Environment variables env: { [string]: string @dagger(input) @@ -31,6 +39,9 @@ import ( // Run this yarn script script: string | *"build" @dagger(input) + // Optional arguments for the script + args: [...string] | *[] @dagger(input) + build: os.#Dir & { from: ctr path: "/build" @@ -38,7 +49,7 @@ import ( ctr: os.#Container & { image: alpine.#Image & { - package: { + "package": package & { bash: "=~5.1" yarn: "=~1.22" } @@ -46,13 +57,17 @@ import ( shell: path: "/bin/bash" command: """ [ -n "$ENVFILE_NAME" ] && echo "$ENVFILE" > "$ENVFILE_NAME" - yarn install --production false - yarn run "$YARN_BUILD_SCRIPT" + yarn --cwd "$YARN_CWD" install --production false + + opts=( $(echo $YARN_ARGS) ) + yarn --cwd "$YARN_CWD" run "$YARN_BUILD_SCRIPT" ${opts[@]} mv "$YARN_BUILD_DIRECTORY" /build """ "env": env & { YARN_BUILD_SCRIPT: script + YARN_ARGS: strings.Join(args, "\n") YARN_CACHE_FOLDER: "/cache/yarn" + YARN_CWD: cwd YARN_BUILD_DIRECTORY: buildDir if writeEnvFile != "" { ENVFILE_NAME: writeEnvFile diff --git a/tests/stdlib/aws/s3/.dagger/env/default/plan/s3.cue b/tests/stdlib/aws/s3/.dagger/env/default/plan/s3.cue index e5a9f690..8968493c 100644 --- a/tests/stdlib/aws/s3/.dagger/env/default/plan/s3.cue +++ b/tests/stdlib/aws/s3/.dagger/env/default/plan/s3.cue @@ -49,3 +49,23 @@ TestS3UploadDir: { file: "foo.txt" } } + +TestS3Sync: { + deploy: s3.#Sync & { + config: TestConfig.awsConfig + source: TestDirectory + target: "s3://\(bucket)/" + } + + verifyFile: #VerifyS3 & { + config: TestConfig.awsConfig + target: deploy.target + file: "dirFile.txt" + } + + verifyDir: #VerifyS3 & { + config: TestConfig.awsConfig + target: deploy.target + file: "foo.txt" + } +} diff --git a/tools/gendocs/.gitignore b/tools/gendocs/.gitignore deleted file mode 100644 index 542ebfb2..00000000 --- a/tools/gendocs/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Typescript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# dotenv environment variable files -.env* - -# gatsby files -.cache/ -public - -# Mac files -.DS_Store - -# Yarn -yarn-error.log -.pnp/ -.pnp.js -# Yarn Integrity file -.yarn-integrity - -.idea/ diff --git a/tools/gendocs/LICENSE b/tools/gendocs/LICENSE deleted file mode 100644 index e74feb36..00000000 --- a/tools/gendocs/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 Rocketseat - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/gendocs/README.md b/tools/gendocs/README.md deleted file mode 100644 index 9dcc6808..00000000 --- a/tools/gendocs/README.md +++ /dev/null @@ -1,61 +0,0 @@ -

- A illustration of file that is the @rocketseat/gatsby-theme-docs logo -

- -

- Gatsby Starter: Rocket Docs -

- -

- Out of the box Gatsby Starter for creating documentation websites easily and quickly. With support for MDX, code highlight, Analytics, SEO and more πŸ”₯ Using the theme: @rocketseat/gatsby-theme-docs -

- -

- PRs welcome! - - License - - - Follow @rocketseat - -

- -## πŸš€ Features - -- πŸ“ MDX for docs; -- πŸ›£ Yaml-based sidebar navigation; -- πŸ“± Responsive and mobile friendly; -- πŸ–₯ Code highlighting with [prism-react-renderer](https://github.com/FormidableLabs/prism-react-renderer) and [react-live](https://github.com/FormidableLabs/react-live) support; -- πŸ₯‡ SEO (Sitemap, schema.org data, Open Graph and Twitter tags). -- πŸ“ˆ Google Analytics support; -- πŸ“„ Custom docs schema; -- πŸ–± Table of Contents; -- ⚑️ Offline Support & WebApp Manifest; -- and much more πŸ”₯ - -## ⚑️ Getting started - -1. Create the website. - - ```sh - npx gatsby new rocket-docs https://github.com/rocketseat/gatsby-starter-rocket-docs - ``` - -2. Start developing. - - ```sh - cd rocket-docs - gatsby develop - ``` - -3. Are you ready for launch? - - Your site is now running at `http://localhost:8000` - -## πŸ“„ Docs - -Looking for docs? Check our live demo and documentation [website](https://rocketdocs.netlify.app). - ---- - -Made with πŸ’œ by Rocketseat :wave: [check our community!](https://discordapp.com/invite/gCRAFhc) diff --git a/tools/gendocs/docs b/tools/gendocs/docs deleted file mode 120000 index 92a7f825..00000000 --- a/tools/gendocs/docs +++ /dev/null @@ -1 +0,0 @@ -../../docs \ No newline at end of file diff --git a/tools/gendocs/gatsby-config.js b/tools/gendocs/gatsby-config.js deleted file mode 100644 index 74f783b3..00000000 --- a/tools/gendocs/gatsby-config.js +++ /dev/null @@ -1,28 +0,0 @@ -module.exports = { - pathPrefix: `/${process.env.VERSION}`, - siteMetadata: { - siteTitle: `Dagger Docs`, - defaultTitle: `Dagger Docs`, - siteTitleShort: `Dagger Docs`, - siteDescription: `Dagger Documentation`, - siteUrl: `https://launch.dagger.io`, - siteAuthor: `@dagger`, - siteImage: `/banner.png`, - siteLanguage: `en`, - themeColor: `#1890FF`, - docVersion : `${process.env.VERSION}`, - }, - flags: { PRESERVE_WEBPACK_CACHE: true }, - plugins: [ - { - resolve: `@rocketseat/gatsby-theme-docs`, - options: { - basePath: `/`, - configPath: `docs/sidebar`, - docsPath: `docs`, - repositoryUrl: `https://github.com/dagger/dagger`, - baseDir: `/`, - }, - }, - ], -}; diff --git a/tools/gendocs/package.json b/tools/gendocs/package.json deleted file mode 100644 index aef687f0..00000000 --- a/tools/gendocs/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "dagger-docs", - "private": true, - "version": "1.0.0", - "description": "dagger dc", - "author": "Dagger", - "license": "MIT", - "starter-name": "dagger-docs-generator", - "dependencies": { - "@rocketseat/gatsby-theme-docs": "^2.3.1", - "gatsby": "^3.0.4", - "gatsby-plugin-canonical-urls": "^3.0.0", - "gatsby-plugin-google-analytics": "^3.0.0", - "gatsby-plugin-manifest": "^3.0.0", - "gatsby-plugin-offline": "^4.0.0", - "gatsby-plugin-remove-trailing-slashes": "^3.0.0", - "gatsby-plugin-sitemap": "^3.0.0", - "prop-types": "^15.7.2", - "react": "^17.0.1", - "react-dom": "^17.0.1" - }, - "devDependencies": {}, - "keywords": [ - "gatsby", - "rocketseat", - "gatsby-starter" - ], - "scripts": { - "build": "gatsby build", - "start": "gatsby develop", - "serve": "gatsby serve", - "clean": "gatsby clean" - } -} diff --git a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/assets/dagger-logo.png b/tools/gendocs/src/@rocketseat/gatsby-theme-docs/assets/dagger-logo.png deleted file mode 100644 index 7c5e64e8..00000000 Binary files a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/assets/dagger-logo.png and /dev/null differ diff --git a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Logos.js b/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Logos.js deleted file mode 100644 index 35cdeea3..00000000 --- a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Logos.js +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react'; -import logo from '../assets/dagger-logo.png' - -export default function Logo(props) { - return Logo -} \ No newline at end of file diff --git a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/ExternalLink/index.js b/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/ExternalLink/index.js deleted file mode 100644 index dcbad43c..00000000 --- a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/ExternalLink/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { FiExternalLink } from 'react-icons/fi'; - -export default function ExternalLink({ link, label }) { - return ( - - {label} - - - ); -} - -ExternalLink.propTypes = { - link: PropTypes.string.isRequired, - label: PropTypes.string.isRequired, -}; diff --git a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/InternalLink/index.js b/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/InternalLink/index.js deleted file mode 100644 index f951b77f..00000000 --- a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/InternalLink/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import {Link} from 'gatsby'; - -export default function InternalLink({ link, label }) { - - return ( - - {label} - - ); -} - -InternalLink.propTypes = { - link: PropTypes.string.isRequired, - label: PropTypes.string.isRequired, -}; diff --git a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/Select/index.js b/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/Select/index.js deleted file mode 100644 index 22b19355..00000000 --- a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/Select/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { Select as SelectStyled } from '../styles'; - -const Select = () => { - const isBrowser = typeof window !== "undefined" - const [tagsList, setTagsList] = useState([]) - const currentLocation = isBrowser ? window.location.pathname.split('/') : [] - currentLocation.shift() //remove last trailing slash - - useEffect(() => { - async function getTags() { - const fetchTags = await fetch('/tags.json').then(result => result.json()); - if (fetchTags.length > 0) { - setTagsList(fetchTags); - } - } - - getTags() - }, []) - - return ( - isBrowser ? window.location.pathname = `/${e.currentTarget.value}` : null}> - {tagsList.map(t => ( - - ))} - - ); -}; - -export default Select; diff --git a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/index.js b/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/index.js deleted file mode 100644 index e1aff7fe..00000000 --- a/tools/gendocs/src/@rocketseat/gatsby-theme-docs/components/Sidebar/index.js +++ /dev/null @@ -1,95 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { useStaticQuery, graphql, Link } from 'gatsby'; -import { useSidebar } from '@rocketseat/gatsby-theme-docs-core'; - -import { - Container, - LogoContainer, - List, - Heading, - Item, - SubItem, -} from './styles'; -import Select from './Select' -import { isExternalUrl } from '../../util/url'; -import ExternalLink from './ExternalLink'; -import InternalLink from './InternalLink'; -import Logo from '../Logos'; - -function ListWithSubItems({ children, text }) { - return ( - <> - {text} - {children} - - ); -} - -export default function Sidebar({ isMenuOpen }) { - const { - site: { - siteMetadata: { basePath }, - }, - } = useStaticQuery(graphql` - { - site { - siteMetadata { - basePath - } - } - } - `); - - const data = useSidebar(); - - function renderLink(link, label) { - return isExternalUrl(link) ? ( - - ) : ( - - ); - } - - return ( - - - - -