docs: move gendocs tool to dagger/dagger
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
b9083f7fea
commit
6ddb973f03
101
.github/workflows/deploy.yml
vendored
101
.github/workflows/deploy.yml
vendored
@ -1,101 +0,0 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: DEPLOY
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- v*
|
||||
paths:
|
||||
- 'doc/**'
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
deploy:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
AWS_DEFAULT_REGION: "eu-west-1"
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
#################################################################
|
||||
# COMMOMS
|
||||
#################################################################
|
||||
# Get current tag (or 'main') in step output for use in uploads
|
||||
- name: Set Tag Name
|
||||
id: vars
|
||||
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
|
||||
|
||||
#################################################################
|
||||
# FETCH GENERATOR + DATA
|
||||
#################################################################
|
||||
|
||||
# fetch gatsby generator from 'dagger/DocGenerator'
|
||||
# then fetch docs data to have generator + data in the context of the job
|
||||
# fetch-depth: '0' enables listing all tags for version selector
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: 'dagger/DocGenerator'
|
||||
ref: 'main'
|
||||
token: ${{ secrets.PAT }} # is a secret that contains your PAT
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
path: 'docsTMP'
|
||||
- run: mkdir -p docs && mv docsTMP/docs/* docs/
|
||||
- run: mv ./docs/index.mdx ./src/@rocketseat/gatsby-theme-docs/text/index.mdx
|
||||
|
||||
#################################################################
|
||||
# BUILD SITE
|
||||
#################################################################
|
||||
|
||||
# Install Node
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "14"
|
||||
- run: yarn
|
||||
- name: Build Site
|
||||
run: yarn build --prefix-paths
|
||||
env:
|
||||
VERSION: ${{steps.vars.outputs.tag}}
|
||||
|
||||
#################################################################
|
||||
# DEPLOY TO S3
|
||||
#################################################################
|
||||
|
||||
|
||||
# deploy the site in the right foder ( tag or main)
|
||||
- name: S3 Sync
|
||||
uses: ItsKarma/aws-cli@v1.70.0
|
||||
with:
|
||||
args: s3 sync --delete --acl public-read public/ s3://daggerdoc.humans-it.com/docs/${{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 --git-dir ./docsTMP/.git tag -l "v*" | tr '\n' '|' | sed -e 's/|/"}, {\"tag\"':' "/g')main\"} "]" > tags.json
|
||||
- name: Copy tags.json
|
||||
uses: ItsKarma/aws-cli@v1.70.0
|
||||
with:
|
||||
args: s3 cp --acl public-read ./tags.json s3://daggerdoc.humans-it.com/
|
||||
|
||||
# landing alway on latest tag
|
||||
# use S3 Rediret objet
|
||||
# upload to /docs/index.html
|
||||
- run: touch index.html
|
||||
- name: Redirect Latest tag on landing
|
||||
if: ${{ steps.vars.outputs.tag != 'main' }}
|
||||
uses: ItsKarma/aws-cli@v1.70.0
|
||||
with:
|
||||
args: s3 cp --cache-control max-age=0 --acl public-read --website-redirect /docs/${{steps.vars.outputs.tag}}/ ./index.html s3://daggerdoc.humans-it.com/docs/
|
78
.github/workflows/docs.yml
vendored
Normal file
78
.github/workflows/docs.yml
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
name: Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- v*
|
||||
paths:
|
||||
- "docs/**"
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
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: "eu-west-1"
|
||||
|
||||
steps:
|
||||
- name: Set Tag Name
|
||||
id: vars
|
||||
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
|
||||
|
||||
# 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
|
||||
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 main)
|
||||
- name: S3 Sync
|
||||
uses: ItsKarma/aws-cli@v1.70.0
|
||||
with:
|
||||
args: s3 sync --delete --acl public-read ./tools/gendocs/public/ s3://daggerdoc.humans-it.com/${{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')main\"} "]" > tags.json
|
||||
- name: Copy tags.json
|
||||
uses: ItsKarma/aws-cli@v1.70.0
|
||||
with:
|
||||
args: s3 cp --acl public-read ./tags.json s3://daggerdoc.humans-it.com/
|
||||
|
||||
# landing alway on latest tag
|
||||
# use S3 Rediret objet
|
||||
# upload to /docs/index.html
|
||||
- run: touch index.html
|
||||
- name: Redirect Latest tag on landing
|
||||
# FIXME
|
||||
# if: ${{ steps.vars.outputs.tag != 'main' }}
|
||||
uses: ItsKarma/aws-cli@v1.70.0
|
||||
with:
|
||||
# FIXME: `--website-redirect` uses a permanent redirect, therefore if
|
||||
# we use the latest version it will be in cache forever.
|
||||
# args: s3 cp --cache-control max-age=0 --acl public-read --website-redirect /docs/${{steps.vars.outputs.tag}}/ ./index.html s3://daggerdoc.humans-it.com/docs/
|
||||
args: s3 cp --cache-control max-age=0 --acl public-read --website-redirect /main/ ./index.html s3://daggerdoc.humans-it.com/
|
@ -1,40 +0,0 @@
|
||||
# Dagger
|
||||
|
||||
Dagger is a programmable deployment system. test deploy
|
||||
|
||||
Using Dagger, software builders can automate the deployment of any application to any infrastructure,
|
||||
in just a few lines of code.
|
||||
|
||||
![image](https://user-images.githubusercontent.com/29565/112705398-d0222980-8e5b-11eb-98b9-32c117a3d606.jpeg)
|
||||
|
||||
The Dagger platform adapts to your application, not the other way around.
|
||||
Thanks to its ecosystem of reusable packages and flexible scripting system, Dagger can be dropped
|
||||
into any software project without requiring changes to its architecture or workflow.
|
||||
Think of it as your "devops superglu".
|
||||
|
||||
No matter how your deployment works under the hood, you can manage it with the same Dagger user interface.
|
||||
This makes developers more productive, because they don't have to learn a new workflow every time their deployment
|
||||
system changes.
|
||||
|
||||
## Learn More
|
||||
|
||||
* [Dagger vs. Other Software](/vs)
|
||||
* [Dagger Programming Guide](/programming)
|
||||
* [Dagger Operator Manual](/operator)
|
||||
|
||||
|
||||
## Download and Install
|
||||
|
||||
* [Install Dagger from source](/install)
|
||||
* Binary distributions [*coming soon*]
|
||||
|
||||
## Community
|
||||
|
||||
Join the [Dagger community chatroom](https://discord.gg/Rmffpmc) on Discord.
|
||||
We welcome beginners and experts alike!
|
||||
|
||||
|
||||
## Alpha disclaimer
|
||||
|
||||
Dagger is *alpha-quality software*. It has many bugs, the user interface is minimal, and it may change in incompatible ways at any time. If you are still willing to try it, thank you! We appreciate your help and encourage you to ask questions and report issues.
|
||||
|
71
tools/gendocs/.gitignore
vendored
Normal file
71
tools/gendocs/.gitignore
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
# 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/
|
21
tools/gendocs/LICENSE
Normal file
21
tools/gendocs/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
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.
|
61
tools/gendocs/README.md
Normal file
61
tools/gendocs/README.md
Normal file
@ -0,0 +1,61 @@
|
||||
<p align="center">
|
||||
<img src="https://rocketseat-cdn.s3-sa-east-1.amazonaws.com/theme-docs.svg" alt="A illustration of file that is the @rocketseat/gatsby-theme-docs logo" width="100">
|
||||
</p>
|
||||
|
||||
<h2 align="center">
|
||||
Gatsby Starter: Rocket Docs
|
||||
</h2>
|
||||
|
||||
<p align="center">
|
||||
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: <a href="https://github.com/Rocketseat/gatsby-themes/tree/main/%40rocketseat/gatsby-theme-docs">@rocketseat/gatsby-theme-docs</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/PRs-welcome-%238257E6.svg" alt="PRs welcome!" />
|
||||
|
||||
<img alt="License" src="https://img.shields.io/badge/license-MIT-%238257E6">
|
||||
|
||||
<a href="https://twitter.com/intent/follow?screen_name=rocketseat">
|
||||
<img src="https://img.shields.io/twitter/follow/rocketseat.svg?label=Follow%20@rocketseat" alt="Follow @rocketseat" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## 🚀 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)
|
1
tools/gendocs/docs
Symbolic link
1
tools/gendocs/docs
Symbolic link
@ -0,0 +1 @@
|
||||
../../docs
|
28
tools/gendocs/gatsby-config.js
Normal file
28
tools/gendocs/gatsby-config.js
Normal file
@ -0,0 +1,28 @@
|
||||
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: `/`,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
34
tools/gendocs/package.json
Normal file
34
tools/gendocs/package.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import logo from '../assets/dagger-logo.jpg'
|
||||
|
||||
export default function Logo(props) {
|
||||
return <img src={logo} alt="Logo" />
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FiExternalLink } from 'react-icons/fi';
|
||||
|
||||
export default function ExternalLink({ link, label }) {
|
||||
return (
|
||||
<a href={link} rel="noopener noreferrer">
|
||||
{label}
|
||||
<FiExternalLink
|
||||
style={{ width: '16px', height: '16px', marginLeft: '10px' }}
|
||||
/>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
ExternalLink.propTypes = {
|
||||
link: PropTypes.string.isRequired,
|
||||
label: PropTypes.string.isRequired,
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {Link} from 'gatsby';
|
||||
|
||||
export default function InternalLink({ link, label }) {
|
||||
|
||||
return (
|
||||
<Link to={link} activeClassName="active-link">
|
||||
{label}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
InternalLink.propTypes = {
|
||||
link: PropTypes.string.isRequired,
|
||||
label: PropTypes.string.isRequired,
|
||||
};
|
@ -0,0 +1,28 @@
|
||||
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.pop() //remove last trailing slash
|
||||
|
||||
useEffect(() => {
|
||||
async function getTags() {
|
||||
const fetchTags = await fetch('https://s3-eu-west-1.amazonaws.com/daggerdoc.humans-it.com/tags.json').then(result => result.json());
|
||||
setTagsList(fetchTags);
|
||||
}
|
||||
|
||||
getTags()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<SelectStyled value={currentLocation[currentLocation.length - 1]} onChange={(e) => isBrowser ? window.location.pathname = `/${e.currentTarget.value}/index.html` : null}>
|
||||
{tagsList.map(t => (
|
||||
<option>{t.tag}</option>
|
||||
))}
|
||||
</SelectStyled>
|
||||
);
|
||||
};
|
||||
|
||||
export default Select;
|
@ -0,0 +1,95 @@
|
||||
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 (
|
||||
<>
|
||||
<Heading>{text}</Heading>
|
||||
<SubItem>{children}</SubItem>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Sidebar({ isMenuOpen }) {
|
||||
const {
|
||||
site: {
|
||||
siteMetadata: { basePath },
|
||||
},
|
||||
} = useStaticQuery(graphql`
|
||||
{
|
||||
site {
|
||||
siteMetadata {
|
||||
basePath
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
const data = useSidebar();
|
||||
|
||||
function renderLink(link, label) {
|
||||
return isExternalUrl(link) ? (
|
||||
<ExternalLink link={link} label={label} />
|
||||
) : (
|
||||
<InternalLink link={link} label={label} />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container isMenuOpen={isMenuOpen}>
|
||||
<LogoContainer>
|
||||
<Link to={basePath} aria-label="Go to home page">
|
||||
<Logo aria-hidden="true" />
|
||||
</Link>
|
||||
</LogoContainer>
|
||||
<Select />
|
||||
<nav>
|
||||
<List>
|
||||
{data.map(({ node: { label, link, items, id } }) => {
|
||||
if (Array.isArray(items)) {
|
||||
const subitems = items.map((item) => (
|
||||
<Item key={item.link}>{renderLink(item.link, item.label)}</Item>
|
||||
));
|
||||
|
||||
return (
|
||||
<ListWithSubItems key={id} text={label}>
|
||||
{subitems}
|
||||
</ListWithSubItems>
|
||||
);
|
||||
}
|
||||
|
||||
return <Item key={id}>{renderLink(link, label)}</Item>;
|
||||
})}
|
||||
</List>
|
||||
</nav>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
ListWithSubItems.propTypes = {
|
||||
children: PropTypes.oneOfType([
|
||||
PropTypes.arrayOf(PropTypes.element),
|
||||
PropTypes.node,
|
||||
]).isRequired,
|
||||
text: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
Sidebar.propTypes = {
|
||||
isMenuOpen: PropTypes.bool.isRequired,
|
||||
};
|
@ -0,0 +1,139 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
export const Container = styled.aside`
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
|
||||
position: sticky;
|
||||
top: 0;
|
||||
padding-top: 36px;
|
||||
transition: transform 0.5s;
|
||||
height: calc(100vh - 1px);
|
||||
|
||||
nav {
|
||||
width: 100%;
|
||||
padding-top: 24px;
|
||||
align-self: flex-start;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 780px) {
|
||||
max-width: 75%;
|
||||
min-width: auto;
|
||||
z-index: 1001;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
padding-top: 32px;
|
||||
background: ${({ theme }) => theme.colors.background};
|
||||
transform: translate3d(
|
||||
${({ isMenuOpen }) => (isMenuOpen ? '0' : '-100%')},
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
`;
|
||||
|
||||
export const LogoContainer = styled.div`
|
||||
width: 70%;
|
||||
|
||||
a {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
}
|
||||
`;
|
||||
|
||||
export const List = styled.ul`
|
||||
list-style: none;
|
||||
width: 100%;
|
||||
padding-left: 0;
|
||||
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
`;
|
||||
|
||||
export const Heading = styled.li`
|
||||
padding-left: 30px;
|
||||
width: 100%;
|
||||
text-transform: uppercase;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin-top: 20px;
|
||||
color: ${({ theme }) => theme.colors.title};
|
||||
letter-spacing: 0.142em;
|
||||
`;
|
||||
|
||||
export const Item = styled.li`
|
||||
font-size: 15px;
|
||||
width: 100%;
|
||||
transition: all 200ms ease-in-out;
|
||||
padding: 0 20px;
|
||||
cursor: pointer;
|
||||
|
||||
a,
|
||||
span {
|
||||
display: block;
|
||||
font-size: 15px;
|
||||
color: ${({ theme }) => theme.colors.text};
|
||||
background-color: ${({ theme }) => theme.colors.background};
|
||||
padding: 4px 10px;
|
||||
margin: 4px 0;
|
||||
border-radius: 4px;
|
||||
font-weight: normal;
|
||||
|
||||
text-decoration: none;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
cursor: pointer;
|
||||
margin: 0 auto;
|
||||
|
||||
transition: all 0.2s ease;
|
||||
|
||||
svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
&:not(.active-link):hover {
|
||||
color: ${({ theme }) => theme.colors.primary};
|
||||
}
|
||||
|
||||
&.active-link {
|
||||
color: ${({ theme }) => theme.colors.primary};
|
||||
background-color: ${({ theme }) => theme.colors.shape};
|
||||
}
|
||||
|
||||
@media (max-width: 780px) {
|
||||
&.active-link {
|
||||
background: ${({ theme }) => theme.colors.shape};
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const SubItem = styled(List)`
|
||||
margin: 5px 0 0 0;
|
||||
`;
|
||||
|
||||
export const Select = styled.select`
|
||||
border: 1px solid #6C6C808C;
|
||||
padding: 0.5rem;
|
||||
margin: 2rem 0 1rem;
|
||||
width: 100%;
|
||||
`;
|
@ -0,0 +1,15 @@
|
||||
export default {
|
||||
colors: {
|
||||
primary: '#1890FF',
|
||||
background: '#FFFFFF',
|
||||
shape: `#F2F2FA`,
|
||||
title: `#3D3D4D`,
|
||||
text: `#6C6C80`,
|
||||
components: {
|
||||
blockquote: {
|
||||
background: `#332616`,
|
||||
text: `#E1E1E6`,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
@ -0,0 +1,27 @@
|
||||
/* eslint-disable */
|
||||
|
||||
export const copyToClipboard = (str) => {
|
||||
const { clipboard } = window.navigator;
|
||||
|
||||
if (!clipboard || typeof clipboard.writeText !== `function`) {
|
||||
const textarea = document.createElement(`textarea`);
|
||||
textarea.value = str;
|
||||
textarea.setAttribute(`readonly`, true);
|
||||
textarea.setAttribute(`contenteditable`, true);
|
||||
textarea.style.position = `absolute`;
|
||||
textarea.style.left = `-9999px`;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
const range = document.createRange();
|
||||
const sel = window.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
textarea.setSelectionRange(0, textarea.value.length);
|
||||
document.execCommand(`copy`);
|
||||
document.body.removeChild(textarea);
|
||||
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
return clipboard.writeText(str);
|
||||
};
|
11
tools/gendocs/src/@rocketseat/gatsby-theme-docs/util/slug.js
Normal file
11
tools/gendocs/src/@rocketseat/gatsby-theme-docs/util/slug.js
Normal file
@ -0,0 +1,11 @@
|
||||
export default function slugify(string) {
|
||||
return string
|
||||
.toString() // Cast to string
|
||||
.toLowerCase() // Convert the string to lowercase letters
|
||||
.trim() // Remove whitespace from both sides of a string
|
||||
.replace(/\s/g, '-') // Replace each space with -
|
||||
.replace(
|
||||
/[^\w\-\u00b4\u00C0-\u00C3\u00c7\u00C9-\u00CA\u00CD\u00D3-\u00D5\u00DA\u00E0-\u00E3\u00E7\u00E9-\u00EA\u00ED\u00F3-\u00F5\u00FA]+/g,
|
||||
'',
|
||||
); // Removes all chars that aren't words, -, ´ or some latin characters (À Á Â Ã Ç É Ê Í Ó Ô Õ Ú à á â ã ç é ê í ó ô õ ú)
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
function isExternalUrl(url) {
|
||||
return new RegExp('^((https?:)?//)', 'i').test(url);
|
||||
}
|
||||
|
||||
module.exports = { isExternalUrl };
|
18
tools/gendocs/src/pages/404.js
Normal file
18
tools/gendocs/src/pages/404.js
Normal file
@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'gatsby';
|
||||
|
||||
import Layout from '@rocketseat/gatsby-theme-docs/src/components/Layout';
|
||||
import SEO from '@rocketseat/gatsby-theme-docs/src/components/SEO';
|
||||
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<Layout title="Page not found!">
|
||||
<SEO title="404: Not found" />
|
||||
<p>You just hit a route that doesn't exist... the sadness.</p>
|
||||
<p>
|
||||
If you'd like to go back to homepage, <Link to="/">click here</Link>
|
||||
.
|
||||
</p>
|
||||
</Layout>
|
||||
);
|
||||
}
|
BIN
tools/gendocs/static/banner.png
Normal file
BIN
tools/gendocs/static/banner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 77 KiB |
BIN
tools/gendocs/static/favicon.png
Normal file
BIN
tools/gendocs/static/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
14640
tools/gendocs/yarn.lock
Normal file
14640
tools/gendocs/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user