mirror of https://github.com/fantasticit/think.git
fix: fix seo title
This commit is contained in:
parent
3e0d8a4781
commit
f1b039a687
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
@ -9,6 +9,10 @@ interface IProps {
|
||||||
const buildTitle = (title) => `${title} - 云策文档`;
|
const buildTitle = (title) => `${title} - 云策文档`;
|
||||||
|
|
||||||
export const Seo: React.FC<IProps> = ({ title, needTitleSuffix = true }) => {
|
export const Seo: React.FC<IProps> = ({ title, needTitleSuffix = true }) => {
|
||||||
|
useEffect(() => {
|
||||||
|
window.document.title = needTitleSuffix ? buildTitle(title) : title;
|
||||||
|
}, [title, needTitleSuffix]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<title>{needTitleSuffix ? buildTitle(title) : title}</title>
|
<title>{needTitleSuffix ? buildTitle(title) : title}</title>
|
||||||
|
|
|
@ -13,8 +13,8 @@ interface IProps {
|
||||||
wikiId: string;
|
wikiId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WorkspaceDocs: React.FC<IProps> = ({ wikiId }) => {
|
export const Documents: React.FC<IProps> = ({ wikiId }) => {
|
||||||
const { data: workspace, loading: workspaceLoading, toggleStatus: toggleWorkspaceStatus } = useWikiDetail(wikiId);
|
const { data: wiki, loading: wikiLoading, toggleStatus: toggleWorkspaceStatus } = useWikiDetail(wikiId);
|
||||||
const { data: tocs, loading } = useWikiTocs(wikiId);
|
const { data: tocs, loading } = useWikiTocs(wikiId);
|
||||||
const documents = flattenTree2Array(tocs).map((d) => {
|
const documents = flattenTree2Array(tocs).map((d) => {
|
||||||
d.label = d.title;
|
d.label = d.title;
|
||||||
|
@ -22,7 +22,7 @@ export const WorkspaceDocs: React.FC<IProps> = ({ wikiId }) => {
|
||||||
return d;
|
return d;
|
||||||
});
|
});
|
||||||
const [nextStatus, setNextStatus] = useState('');
|
const [nextStatus, setNextStatus] = useState('');
|
||||||
const isPublic = useMemo(() => workspace && isPublicWiki(workspace.status), [workspace]);
|
const isPublic = useMemo(() => wiki && isPublicWiki(wiki.status), [wiki]);
|
||||||
const [publicDocumentIds, setPublicDocumentIds] = useState([]); // 公开的
|
const [publicDocumentIds, setPublicDocumentIds] = useState([]); // 公开的
|
||||||
const privateDocumentIds = useMemo(() => {
|
const privateDocumentIds = useMemo(() => {
|
||||||
return documents.filter((doc) => !publicDocumentIds.includes(doc.id)).map((doc) => doc.id);
|
return documents.filter((doc) => !publicDocumentIds.includes(doc.id)).map((doc) => doc.id);
|
||||||
|
@ -69,9 +69,9 @@ export const WorkspaceDocs: React.FC<IProps> = ({ wikiId }) => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!workspace) return;
|
if (!wiki) return;
|
||||||
setNextStatus(workspace.status);
|
setNextStatus(wiki.status);
|
||||||
}, [workspace]);
|
}, [wiki]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!documents.length) return;
|
if (!documents.length) return;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Tabs, TabPane } from '@douyinfe/semi-ui';
|
import { Tabs, TabPane } from '@douyinfe/semi-ui';
|
||||||
|
import { Seo } from 'components/seo';
|
||||||
import { useWikiDetail } from 'data/wiki';
|
import { useWikiDetail } from 'data/wiki';
|
||||||
import { Base } from './base';
|
import { Base } from './base';
|
||||||
import { Users } from './users';
|
import { Users } from './users';
|
||||||
import { WorkspaceDocs } from './documents';
|
import { Documents } from './documents';
|
||||||
import { More } from './more';
|
import { More } from './more';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
@ -12,23 +13,33 @@ interface IProps {
|
||||||
onNavigate: (arg: string) => void;
|
onNavigate: (arg: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TitleMap = {
|
||||||
|
base: '基础信息',
|
||||||
|
users: '成员管理',
|
||||||
|
docs: '隐私管理',
|
||||||
|
more: '更多',
|
||||||
|
};
|
||||||
|
|
||||||
export const WikiSetting: React.FC<IProps> = ({ wikiId, tab, onNavigate }) => {
|
export const WikiSetting: React.FC<IProps> = ({ wikiId, tab, onNavigate }) => {
|
||||||
const { data, loading, error, update } = useWikiDetail(wikiId);
|
const { data, update } = useWikiDetail(wikiId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
<Seo title={TitleMap[tab]} />
|
||||||
<Tabs lazyRender type="line" activeKey={tab} onChange={onNavigate}>
|
<Tabs lazyRender type="line" activeKey={tab} onChange={onNavigate}>
|
||||||
<TabPane tab="基础信息" itemKey="base">
|
<TabPane tab={TitleMap['base']} itemKey="base">
|
||||||
<Base wiki={data} update={update as any} />
|
<Base wiki={data} update={update as any} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="成员管理" itemKey="users">
|
<TabPane tab={TitleMap['users']} itemKey="users">
|
||||||
<Users wikiId={wikiId} />
|
<Users wikiId={wikiId} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="隐私管理" itemKey="docs">
|
<TabPane tab={TitleMap['docs']} itemKey="docs">
|
||||||
<WorkspaceDocs wikiId={wikiId} />
|
<Documents wikiId={wikiId} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="更多" itemKey="more">
|
<TabPane tab={TitleMap['more']} itemKey="more">
|
||||||
<More wikiId={wikiId} />
|
<More wikiId={wikiId} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,8 +4,6 @@ import { Avatar, Button, Typography, Skeleton, Tooltip } from '@douyinfe/semi-ui
|
||||||
import { IconPlus } from '@douyinfe/semi-icons';
|
import { IconPlus } from '@douyinfe/semi-icons';
|
||||||
import { isPublicWiki } from '@think/domains';
|
import { isPublicWiki } from '@think/domains';
|
||||||
import { useWikiDetail, useWikiTocs } from 'data/wiki';
|
import { useWikiDetail, useWikiTocs } from 'data/wiki';
|
||||||
import { useToggle } from 'hooks/use-toggle';
|
|
||||||
import { Seo } from 'components/seo';
|
|
||||||
import { findParents } from 'components/wiki/tocs/utils';
|
import { findParents } from 'components/wiki/tocs/utils';
|
||||||
import { IconDocument, IconSetting, IconOverview, IconGlobe } from 'components/icons';
|
import { IconDocument, IconSetting, IconOverview, IconGlobe } from 'components/icons';
|
||||||
import { DataRender } from 'components/data-render';
|
import { DataRender } from 'components/data-render';
|
||||||
|
@ -19,20 +17,19 @@ interface IProps {
|
||||||
documentId?: string;
|
documentId?: string;
|
||||||
docAsLink?: string;
|
docAsLink?: string;
|
||||||
getDocLink?: (arg: string) => string;
|
getDocLink?: (arg: string) => string;
|
||||||
pageTitle: string;
|
// pageTitle: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
export const WikiTocs: React.FC<IProps> = ({
|
export const WikiTocs: React.FC<IProps> = ({
|
||||||
pageTitle,
|
// pageTitle,
|
||||||
wikiId,
|
wikiId,
|
||||||
documentId = null,
|
documentId = null,
|
||||||
docAsLink = '/wiki/[wikiId]/document/[documentId]',
|
docAsLink = '/wiki/[wikiId]/document/[documentId]',
|
||||||
getDocLink = (documentId) => `/wiki/${wikiId}/document/${documentId}`,
|
getDocLink = (documentId) => `/wiki/${wikiId}/document/${documentId}`,
|
||||||
}) => {
|
}) => {
|
||||||
const { pathname } = useRouter();
|
const { pathname } = useRouter();
|
||||||
const [visible, toggleVisible] = useToggle(false);
|
|
||||||
const { data: wiki, loading: wikiLoading, error: wikiError } = useWikiDetail(wikiId);
|
const { data: wiki, loading: wikiLoading, error: wikiError } = useWikiDetail(wikiId);
|
||||||
const { data: tocs, loading: tocsLoading, error: tocsError, refresh } = useWikiTocs(wikiId);
|
const { data: tocs, loading: tocsLoading, error: tocsError, refresh } = useWikiTocs(wikiId);
|
||||||
const [parentIds, setParentIds] = useState<Array<string>>([]);
|
const [parentIds, setParentIds] = useState<Array<string>>([]);
|
||||||
|
@ -74,8 +71,6 @@ export const WikiTocs: React.FC<IProps> = ({
|
||||||
}
|
}
|
||||||
error={wikiError}
|
error={wikiError}
|
||||||
normalContent={() => (
|
normalContent={() => (
|
||||||
<>
|
|
||||||
<Seo title={wiki.name + ' - ' + pageTitle} />
|
|
||||||
<NavItem
|
<NavItem
|
||||||
icon={
|
icon={
|
||||||
<Avatar
|
<Avatar
|
||||||
|
@ -95,7 +90,6 @@ export const WikiTocs: React.FC<IProps> = ({
|
||||||
text={<Text strong>{wiki.name}</Text>}
|
text={<Text strong>{wiki.name}</Text>}
|
||||||
hoverable={false}
|
hoverable={false}
|
||||||
/>
|
/>
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
import { NextPage } from 'next';
|
import { NextPage } from 'next';
|
||||||
import Router, { useRouter } from 'next/router';
|
import Router, { useRouter } from 'next/router';
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { Typography, List, Tabs, TabPane, Tree } from '@douyinfe/semi-ui';
|
import { Typography, List, Tabs, TabPane } from '@douyinfe/semi-ui';
|
||||||
import { CreateDocumentIllustration } from 'illustrations/create-document';
|
import { CreateDocumentIllustration } from 'illustrations/create-document';
|
||||||
import { DoubleColumnLayout } from 'layouts/double-column';
|
import { DoubleColumnLayout } from 'layouts/double-column';
|
||||||
|
import { Seo } from 'components/seo';
|
||||||
import { DataRender } from 'components/data-render';
|
import { DataRender } from 'components/data-render';
|
||||||
import { WikiTocs } from 'components/wiki/tocs';
|
import { WikiTocs } from 'components/wiki/tocs';
|
||||||
import { WikiTocsManager } from 'components/wiki/tocs/manager';
|
import { WikiTocsManager } from 'components/wiki/tocs/manager';
|
||||||
import { useWikiDocs } from 'data/wiki';
|
|
||||||
import { DocumentCardPlaceholder, DocumentCard } from 'components/document/card';
|
import { DocumentCardPlaceholder, DocumentCard } from 'components/document/card';
|
||||||
import { Empty } from 'components/empty';
|
import { Empty } from 'components/empty';
|
||||||
import { DocumentCreator } from 'components/document-creator';
|
import { DocumentCreator } from 'components/document-creator';
|
||||||
|
import { useWikiDocs } from 'data/wiki';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
wikiId: string;
|
wikiId: string;
|
||||||
|
@ -79,9 +80,10 @@ const Page: NextPage<IProps> = ({ wikiId }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DoubleColumnLayout
|
<DoubleColumnLayout
|
||||||
leftNode={<WikiTocs pageTitle="文档管理" wikiId={wikiId} />}
|
leftNode={<WikiTocs wikiId={wikiId} />}
|
||||||
rightNode={
|
rightNode={
|
||||||
<>
|
<>
|
||||||
|
<Seo title={tab === 'documents' ? '全部文档' : '目录管理'} />
|
||||||
<Title heading={3} style={{ marginBottom: 24 }}>
|
<Title heading={3} style={{ marginBottom: 24 }}>
|
||||||
文档管理
|
文档管理
|
||||||
</Title>
|
</Title>
|
||||||
|
|
|
@ -26,9 +26,9 @@ const Page: NextPage<IProps> = ({ wikiId }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DoubleColumnLayout
|
<DoubleColumnLayout
|
||||||
leftNode={<WikiTocs pageTitle="设置" wikiId={wikiId} />}
|
leftNode={<WikiTocs wikiId={wikiId} />}
|
||||||
rightNode={<WikiSetting wikiId={wikiId} tab={tab} onNavigate={(tab) => navigate(tab)()} />}
|
rightNode={<WikiSetting wikiId={wikiId} tab={tab} onNavigate={(tab) => navigate(tab)()} />}
|
||||||
></DoubleColumnLayout>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue