-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #555 from sebgroup/develop
release new doc
- Loading branch information
Showing
75 changed files
with
2,596 additions
and
1,768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,27 +5,120 @@ on: | |
branches: [master, beta] | ||
|
||
jobs: | ||
get_tags: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Get list of releases 📋 | ||
uses: octokit/[email protected] | ||
id: get_latest_release | ||
with: | ||
route: GET /repos/kherp/react-components/tags | ||
owner: octokit | ||
repo: request-action | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Convert list of releases to json and filter out versions less than minimum version 📝 | ||
id: set-matrix | ||
run: | | ||
arr=( $(echo $data | jq -r '.[].name') ) | ||
major="" | ||
JSON="{\"include\":[" | ||
for i in "${arr[@]}" | ||
do | ||
if [ "$(printf '%s\n' "$minver" "$i" | sort -V | head -n1)" = "$minver" ]; then | ||
if [ "$major" != "$(echo $i | cut -d. -f1)" ]; then | ||
major=`echo $i | cut -d. -f1` | ||
JSON="$JSON$(printf '{"name": "%s"}, ' "${i}")" | ||
fi | ||
fi | ||
done | ||
JSON="${JSON%,*} ${JSON##*,}" | ||
JSON="$JSON]}" | ||
echo "test: $JSON" | ||
echo "::set-output name=matrix::$JSON" | ||
env: | ||
data: ${{steps.get_latest_release.outputs.data}} | ||
minver: v4.0.0 | ||
gh_pages: | ||
needs: get_tags | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
matrix: ${{ needs.get_tags.outputs.matrix }} | ||
path: ${{ steps.get_version_list.outputs.path }} | ||
file: ${{ steps.get_version_list.outputs.file }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Node | ||
- name: Setup Node 🏗️ | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.x | ||
|
||
- name: Installing dependencies | ||
- name: Installing dependencies ⏳ | ||
run: npm ci | ||
|
||
- name: Building docs | ||
- name: Generating versions list | ||
id: get_version_list | ||
run: | | ||
echo "$data" > $jsonPath$jsonFileName | ||
echo "::set-output name=path::$jsonPath" | ||
echo "::set-output name=file::$jsonFileName" | ||
env: | ||
data: ${{needs.get_tags.outputs.matrix}} | ||
jsonPath: ./docs/src/assets/jsons/ | ||
jsonFileName: versions.json | ||
- name: Building docs 🔨 | ||
run: npm run build:docs | ||
|
||
- name: Publish | ||
- name: Publish 🚀 | ||
uses: crazy-max/[email protected] | ||
with: | ||
build_dir: docs/public | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
build_docs: | ||
needs: gh_pages | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 1 | ||
matrix: ${{fromJson(needs.gh_pages.outputs.matrix)}} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ matrix.name }} | ||
- name: Setup Node 🏗️ | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.x | ||
- name: Installing dependencies ⏳ | ||
run: npm ci | ||
- name: Building docs 🔨 | ||
id: get_doc_folder | ||
run: | | ||
if [ "$(printf '%s\n' "$requiredver" "$currentver" | sort -V | head -n1)" = "$requiredver" ]; then | ||
echo "base=\"/react-components/${currentver}\"" >> .env | ||
mkdir -p $jsonPath && touch $jsonPath$jsonFile | ||
echo "$data" > $jsonPath$jsonFile | ||
npm run build:docs | ||
echo "::set-output name=doc_folder::docs/public" | ||
else | ||
npm run docs | ||
echo "::set-output name=doc_folder::docs" | ||
fi | ||
env: | ||
requiredver: v5.0.0 # oldest version where gatsby is implemented | ||
data: ${{needs.gh_pages.outputs.matrix}} | ||
jsonPath: ${{ needs.gh_pages.outputs.path }} | ||
jsonFile: ${{ needs.gh_pages.outputs.file }} | ||
currentver: ${{ matrix.name }} | ||
- name: Deploy 🚀 | ||
uses: JamesIves/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BRANCH: gh-pages # The branch the action should deploy to. | ||
FOLDER: ${{steps.get_doc_folder.outputs.doc_folder}} # The folder the action should deploy. | ||
TARGET_FOLDER: ${{ matrix.name }} | ||
CLEAN: true # Automatically remove deleted files from the deploy branch | ||
CLEAN_EXCLUDE: '["version"]' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"include": [ | ||
{ "name": "v5.0.0-beta.3" }, | ||
{ "name": "v5.0.0-beta.2" }, | ||
{ "name": "v5.0.0-beta.1" }, | ||
{ "name": "v4.5.2" }, | ||
{ "name": "v4.5.1" }, | ||
{ "name": "v4.5.0" }, | ||
{ "name": "v4.4.1" }, | ||
{ "name": "v4.4.0" }, | ||
{ "name": "v4.3.1" }, | ||
{ "name": "v4.3.0" }, | ||
{ "name": "v4.2.1" }, | ||
{ "name": "v4.2.0" }, | ||
{ "name": "v4.1.0" }, | ||
{ "name": "v4.0.1" }, | ||
{ "name": "v4.0.0" }, | ||
{ "name": "v3.2.0" }, | ||
{ "name": "v3.1.0" }, | ||
{ "name": "v3.0.3" }, | ||
{ "name": "v3.0.2" }, | ||
{ "name": "v3.0.1" }, | ||
{ "name": "v3.0.0" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from "react"; | ||
import classnames from "classnames"; | ||
import { Dropdown } from "@sebgroup/react-components/Dropdown"; | ||
import { withPrefix } from "gatsby-link"; | ||
import "../styles/versions-dropdown.scss"; | ||
const versions = require("../assets/jsons/versions.json").include; | ||
|
||
interface VersionItem { | ||
name: string; | ||
} | ||
interface FormattedVersionItem { | ||
value: string; | ||
label: string; | ||
} | ||
|
||
export interface VersionsDropdownProps { | ||
className?: string; | ||
} | ||
|
||
const VersionsDropdown: React.FC<React.PropsWithChildren<VersionsDropdownProps>> = (props: VersionsDropdownProps) => { | ||
const [currentVersion, setCurrentVersion] = React.useState<string>(""); | ||
const [formattedList, setFormattedList] = React.useState<Array<FormattedVersionItem>>([]); | ||
|
||
/** format dropdown list */ | ||
const formatList = () => { | ||
setFormattedList( | ||
versions?.length > 0 | ||
? versions.map((item: VersionItem) => ({ | ||
value: item.name, | ||
label: item.name.replace(/[^.]+$/, "x"), | ||
})) | ||
: [] | ||
); | ||
}; | ||
|
||
React.useEffect(() => { | ||
const currentpath: string = window.location.href; | ||
const regex: RegExp = new RegExp("v(\\d+\\.)(\\d+\\.)(\\d)(-(beta|alpha)(\\.\\d))?", "g"); | ||
const matchedVersions: Array<string> = currentpath.match(regex); | ||
setCurrentVersion(matchedVersions?.length > 0 ? matchedVersions[0] : versions[0].name); | ||
formatList(); | ||
}, []); | ||
|
||
return ( | ||
<Dropdown | ||
wrapperProps={{ className: classnames("version-dropdown", props.className) }} | ||
value={currentVersion} | ||
selectedLabel={(value: string) => formattedList.find((item: FormattedVersionItem) => item.value === value)?.label} | ||
onChange={(e: React.ChangeEvent<HTMLSelectElement>) => (window.location.href = `${window.location.origin}${withPrefix(e.target.value)}/`)} | ||
> | ||
{formattedList.map((item: FormattedVersionItem, index: number) => ( | ||
<option key={index} value={item.value}> | ||
{item.label} | ||
</option> | ||
))} | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default VersionsDropdown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.