Skip to content

Commit

Permalink
fix: page type account for site root
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Mar 13, 2021
1 parent ce6c06c commit de2faf1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ui/blocks/src/PageTypeTag/PageTypeTag.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { FC, useState, useEffect } from 'react';
import { DocType } from '@component-controls/core';
import { DocType, getDocTypePath } from '@component-controls/core';
import {
Tag,
Link,
getAccentPaletteColor,
} from '@component-controls/components';
import { useDocPropCount, useConfig } from '@component-controls/store';
import { useDocPropCount, useStore } from '@component-controls/store';

export interface PageTypeTagProps {
/**
Expand All @@ -18,7 +18,8 @@ export interface PageTypeTagProps {
raw?: string;
}
export const PageTypeTag: FC<PageTypeTagProps> = ({ type, raw }) => {
const config = useConfig();
const store = useStore();
const { config } = store;
const tags = useDocPropCount('type');
const [colors, setColors] = useState<{ [key: string]: string }>({});

Expand All @@ -34,7 +35,7 @@ export const PageTypeTag: FC<PageTypeTagProps> = ({ type, raw }) => {
);
}, [tags]);
return (
<Link href={`/${config.pages?.[type].basePath}`}>
<Link href={getDocTypePath(store, config.pages?.[type].basePath)}>
<Tag color={colors[type] || '#f49342'} raw={raw}>
{type}
</Tag>
Expand Down

0 comments on commit de2faf1

Please sign in to comment.