refactor(core): use new backlink indexer (#7296)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type { DocService } from '@toeverything/infra';
|
||||
import { Entity, LiveData } from '@toeverything/infra';
|
||||
|
||||
import type { DocsSearchService } from '../../docs-search';
|
||||
|
||||
interface Backlink {
|
||||
docId: string;
|
||||
blockId: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export class DocBacklinks extends Entity {
|
||||
constructor(
|
||||
private readonly docsSearchService: DocsSearchService,
|
||||
private readonly docService: DocService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
backlinks$ = LiveData.from<Backlink[]>(
|
||||
this.docsSearchService.watchRefsTo(this.docService.doc.id),
|
||||
[]
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { DocService } from '@toeverything/infra';
|
||||
import { Entity, LiveData } from '@toeverything/infra';
|
||||
|
||||
import type { DocsSearchService } from '../../docs-search';
|
||||
|
||||
interface Link {
|
||||
docId: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
export class DocLinks extends Entity {
|
||||
constructor(
|
||||
private readonly docsSearchService: DocsSearchService,
|
||||
private readonly docService: DocService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
links$ = LiveData.from<Link[]>(
|
||||
this.docsSearchService.watchRefsFrom(this.docService.doc.id),
|
||||
[]
|
||||
);
|
||||
}
|
||||
22
packages/frontend/core/src/modules/doc-link/index.ts
Normal file
22
packages/frontend/core/src/modules/doc-link/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import {
|
||||
DocScope,
|
||||
DocService,
|
||||
type Framework,
|
||||
WorkspaceScope,
|
||||
} from '@toeverything/infra';
|
||||
|
||||
import { DocsSearchService } from '../docs-search';
|
||||
import { DocBacklinks } from './entities/doc-backlinks';
|
||||
import { DocLinks } from './entities/doc-links';
|
||||
import { DocLinksService } from './services/doc-links';
|
||||
|
||||
export { DocLinksService } from './services/doc-links';
|
||||
|
||||
export function configureDocLinksModule(framework: Framework) {
|
||||
framework
|
||||
.scope(WorkspaceScope)
|
||||
.scope(DocScope)
|
||||
.service(DocLinksService)
|
||||
.entity(DocBacklinks, [DocsSearchService, DocService])
|
||||
.entity(DocLinks, [DocsSearchService, DocService]);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Service } from '@toeverything/infra';
|
||||
|
||||
import { DocBacklinks } from '../entities/doc-backlinks';
|
||||
import { DocLinks } from '../entities/doc-links';
|
||||
|
||||
export class DocLinksService extends Service {
|
||||
backlinks = this.framework.createEntity(DocBacklinks);
|
||||
links = this.framework.createEntity(DocLinks);
|
||||
}
|
||||
Reference in New Issue
Block a user