Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
chore: prettier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jan 21, 2019
1 parent c2554b8 commit 5a4d329
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
4 changes: 3 additions & 1 deletion core/docz-core/src/states/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const updateEntries = (entries: Entries) => async (p: Params) => {

export const state = (entries: Entries, config: Config): State => {
const src = path.relative(paths.root, config.src)
const files = Array.isArray(config.files) ? config.files.map(filePath => path.join(src, filePath)) : path.join(src, config.files)
const files = Array.isArray(config.files)
? config.files.map(filePath => path.join(src, filePath))
: path.join(src, config.files)
const watcher = chokidar.watch(files, {
cwd: paths.root,
ignored: /(((^|[\/\\])\..+)|(node_modules))/,
Expand Down
48 changes: 29 additions & 19 deletions core/docz-theme-default/src/components/ui/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,35 @@ export const LinkStyled = styled('a')`
type LinkProps = React.AnchorHTMLAttributes<any>

export const Link: SFC<LinkProps> = ({ href, ...props }) => {
return <Docs>
{({ docs, config: { separator } }) => {
// calculate matched route
const matched = docs.find(doc => doc.filepath === [
location.pathname.split(separator).slice(0, -1).join(separator).slice(1),
(href || '').replace(/^(?:\.\/)+/gi, '')
].join('/'))
matched && (href = matched.route)
return (
<Docs>
{({ docs, config: { separator } }) => {
// calculate matched route
const matched = docs.find(
doc =>
doc.filepath ===
[
location.pathname
.split(separator)
.slice(0, -1)
.join(separator)
.slice(1),
(href || '').replace(/^(?:\.\/)+/gi, ''),
].join('/')
)
matched && (href = matched.route)

const isInternal = href && href.startsWith('/')
const Component = isInternal
? LinkStyled.withComponent(BaseLink as any)
: LinkStyled
const isInternal = href && href.startsWith('/')
const Component = isInternal
? LinkStyled.withComponent(BaseLink as any)
: LinkStyled

return isInternal ? (
<Component {...props} to={href} />
) : (
<Component {...props} href={href} />
)
}}
</Docs>
return isInternal ? (
<Component {...props} to={href} />
) : (
<Component {...props} href={href} />
)
}}
</Docs>
)
}

0 comments on commit 5a4d329

Please sign in to comment.