mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 12:30:32 +09:00
docs: update document
This commit is contained in:
parent
768738ab14
commit
dc0bc8fec4
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Setup environment
|
## Setup environment
|
||||||
|
|
||||||
Install `now` for development:
|
Install `now` for development server:
|
||||||
|
|
||||||
```
|
```
|
||||||
yarn global add now
|
yarn global add now
|
||||||
@ -17,30 +17,29 @@ yarn start
|
|||||||
|
|
||||||
## Add new provider
|
## Add new provider
|
||||||
|
|
||||||
Create `web/src/components/cards/<NewCard>.js` and paste following GitHub example into it:
|
Create `web/src/components/cards/<NewCard>.js` and paste following template into it:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { FaGithub } from 'react-icons/fa'
|
import { FaGithub } from 'react-icons/fa'
|
||||||
|
|
||||||
import { Card } from '../Card'
|
import { Card } from '../Card'
|
||||||
import { DedicatedAvailability } from '../Availability'
|
import { ExistentialAvailability } from '../Availability'
|
||||||
import { capitalize } from '../../util/text'
|
import { capitalize } from '../../util/text'
|
||||||
|
|
||||||
export default function CratesioCard({ name }) {
|
export default function NewCard({ name }) {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
title="GitHub"
|
title="NewCard"
|
||||||
key={name}
|
key={name}
|
||||||
nameList={[name, `${name}-team`]}
|
nameList={[name, `${name}-team`]}
|
||||||
alternativeList={[`${capitalize(name)}HQ`]}>
|
alternativeList={[`${capitalize(name)}HQ`]}>
|
||||||
{(name) => (
|
{(name) => (
|
||||||
<DedicatedAvailability
|
<ExistentialAvailability
|
||||||
name={name}
|
name={name}
|
||||||
service="github"
|
target={`https://api.newservice.com/items/${name}`}
|
||||||
link={`https://github.com/${name}`}
|
link={`https://newservice.com/${name}`}
|
||||||
prefix="github.com/"
|
prefix="newservice.com/"
|
||||||
suffix=""
|
|
||||||
icon={<FaGithub />}
|
icon={<FaGithub />}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -49,6 +48,31 @@ export default function CratesioCard({ name }) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
and add the card to `/web/src/App.js`:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
import NewCard from './components/cards/NewCard'
|
||||||
|
```
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
<Cards>
|
||||||
|
<CardHeader>Result for {query}</CardHeader>
|
||||||
|
<CardContainer>
|
||||||
|
<GithubCard name={query} />
|
||||||
|
<DomainCard name={query} />
|
||||||
|
<TwitterCard name={query} />
|
||||||
|
<HomebrewCard name={query} />
|
||||||
|
<NpmCard name={query} />
|
||||||
|
<PypiCard name={query} />
|
||||||
|
<CratesioCard name={query} />
|
||||||
|
<JsOrgCard name={query} />
|
||||||
|
<SlackCard name={query} />
|
||||||
|
<S3Card name={query} />
|
||||||
|
<NewCard name={query} />
|
||||||
|
</CardContainer>
|
||||||
|
</Cards>
|
||||||
|
```
|
||||||
|
|
||||||
### ExistentialAvailability
|
### ExistentialAvailability
|
||||||
|
|
||||||
`ExistentialAvailability` check if the response from passed URL returns `404` or not.
|
`ExistentialAvailability` check if the response from passed URL returns `404` or not.
|
||||||
@ -57,4 +81,8 @@ For example, `<ExistentialAvailability target="https://formulae.brew.sh/api/form
|
|||||||
### DedicatedAvailability
|
### DedicatedAvailability
|
||||||
|
|
||||||
`DedicatedAvailability` is for interacting with defined API endpoint to check availability.
|
`DedicatedAvailability` is for interacting with defined API endpoint to check availability.
|
||||||
For example, `<DedicatedAvailability service="github" />` will send a request to `https://namae.dev/availability/<github>/<query>` which is routed to `/api/services/github.js` in the repo.
|
For example, `<DedicatedAvailability service="<service>" />` will send a request to `https://namae.dev/availability/<service>/<query>` which is routed to `/api/services/<service>.js` in the repo.
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
@ -4,6 +4,8 @@ import styled from 'styled-components'
|
|||||||
import { useDeferredState } from './hooks/state'
|
import { useDeferredState } from './hooks/state'
|
||||||
import { mobile } from './util/css'
|
import { mobile } from './util/css'
|
||||||
|
|
||||||
|
import Footer from './components/Footer'
|
||||||
|
|
||||||
import GithubCard from './components/cards/GithubCard'
|
import GithubCard from './components/cards/GithubCard'
|
||||||
import DomainCard from './components/cards/DomainCard'
|
import DomainCard from './components/cards/DomainCard'
|
||||||
import HomebrewCard from './components/cards/HomebrewCard'
|
import HomebrewCard from './components/cards/HomebrewCard'
|
||||||
@ -14,7 +16,6 @@ import JsOrgCard from './components/cards/JsOrgCard'
|
|||||||
import PypiCard from './components/cards/PypiCard'
|
import PypiCard from './components/cards/PypiCard'
|
||||||
import S3Card from './components/cards/S3Card'
|
import S3Card from './components/cards/S3Card'
|
||||||
import CratesioCard from './components/cards/CratesioCard'
|
import CratesioCard from './components/cards/CratesioCard'
|
||||||
import Footer from './components/Footer'
|
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [query, setQuery] = useDeferredState(1000)
|
const [query, setQuery] = useDeferredState(1000)
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { FaTwitter, FaGlobe } from 'react-icons/fa'
|
import { FaTwitter, FaGithubAlt } from 'react-icons/fa'
|
||||||
|
|
||||||
export default function Footer() {
|
export default function Footer() {
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<p>
|
<p>
|
||||||
Made by U with{' '}
|
Made by U with{' '}
|
||||||
<span role="img" aria-label="love">
|
<span role="img" aria-label="coffee">
|
||||||
🐤
|
☕️
|
||||||
</span>
|
</span>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
@ -18,8 +18,11 @@ export default function Footer() {
|
|||||||
rel="noopener noreferrer">
|
rel="noopener noreferrer">
|
||||||
<FaTwitter />
|
<FaTwitter />
|
||||||
</a>{' '}
|
</a>{' '}
|
||||||
<a href="https://uechi.io" target="_blank" rel="noopener noreferrer">
|
<a
|
||||||
<FaGlobe />
|
href="https://github.com/uetchy/namae"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer">
|
||||||
|
<FaGithubAlt />
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</Container>
|
</Container>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user