mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-05-08 22:07:32 +08:00
fix: ci
This commit is contained in:
@@ -120,6 +120,14 @@ export default defineConfig({
|
||||
|
||||
search: {
|
||||
provider: 'local',
|
||||
options: {
|
||||
_render(src, env, md) {
|
||||
if (env.relativePath.startsWith('api/')) {
|
||||
return '';
|
||||
}
|
||||
return md.render(src, env);
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
markdown: {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { existsSync, readdirSync } from 'node:fs';
|
||||
import { join, parse } from 'node:path';
|
||||
|
||||
import type { DefaultTheme } from 'vitepress';
|
||||
|
||||
export const guide: DefaultTheme.NavItem[] = [
|
||||
@@ -100,17 +103,48 @@ export const guide: DefaultTheme.NavItem[] = [
|
||||
export const reference: DefaultTheme.NavItem[] = [
|
||||
{
|
||||
text: 'API Reference',
|
||||
items: [
|
||||
{ text: '@blocksuite/store', link: 'api/@blocksuite/store/index' },
|
||||
{
|
||||
text: '@blocksuite/block-std',
|
||||
link: 'api/@blocksuite/block-std/index',
|
||||
},
|
||||
{ text: '@blocksuite/inline', link: 'api/@blocksuite/inline/index' },
|
||||
],
|
||||
items: getApiReferenceItems(),
|
||||
},
|
||||
];
|
||||
|
||||
function getApiReferenceItems(): DefaultTheme.NavItem[] {
|
||||
const apiDir = join(process.cwd(), 'api', '@blocksuite');
|
||||
|
||||
if (!existsSync(apiDir)) {
|
||||
return [
|
||||
{ text: '@blocksuite/store', link: 'api/@blocksuite/store' },
|
||||
{ text: '@blocksuite/std', link: 'api/@blocksuite/std/index' },
|
||||
{ text: '@blocksuite/affine', link: 'api/@blocksuite/affine' },
|
||||
];
|
||||
}
|
||||
|
||||
return readdirSync(apiDir, { withFileTypes: true })
|
||||
.flatMap(entry => {
|
||||
if (entry.isFile() && entry.name.endsWith('.md')) {
|
||||
const name = parse(entry.name).name;
|
||||
return [
|
||||
{ text: `@blocksuite/${name}`, link: `api/@blocksuite/${name}` },
|
||||
];
|
||||
}
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
const indexPath = join(apiDir, entry.name, 'index.md');
|
||||
|
||||
if (existsSync(indexPath)) {
|
||||
return [
|
||||
{
|
||||
text: `@blocksuite/${entry.name}`,
|
||||
link: `api/@blocksuite/${entry.name}/index`,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
})
|
||||
.sort((a, b) => a.text.localeCompare(b.text));
|
||||
}
|
||||
|
||||
export const components: DefaultTheme.NavItem[] = [
|
||||
{
|
||||
text: 'Introduction',
|
||||
|
||||
7
blocksuite/docs-site/copy-pages-worker.mjs
Normal file
7
blocksuite/docs-site/copy-pages-worker.mjs
Normal file
@@ -0,0 +1,7 @@
|
||||
import { copyFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
copyFileSync(
|
||||
join(process.cwd(), 'pages-worker.mjs'),
|
||||
join(process.cwd(), '.vitepress', 'dist', '_worker.js')
|
||||
);
|
||||
@@ -8,10 +8,11 @@
|
||||
"license": "MPL-2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"typedoc": "typedoc --options ./typedoc.json",
|
||||
"build:deps": "tsc -b ../affine/all",
|
||||
"typedoc": "yarn run build:deps && typedoc --options ./typedoc.json",
|
||||
"dev": "yarn run typedoc && yarn exec vitepress dev --port 5200",
|
||||
"dev:nobuild": "yarn exec vitepress dev --port 5200",
|
||||
"build": "yarn run typedoc && NODE_OPTIONS=--max-old-space-size=8192 yarn exec vitepress build",
|
||||
"build": "yarn run typedoc && NODE_OPTIONS=--max-old-space-size=8192 yarn exec vitepress build && node ./copy-pages-worker.mjs",
|
||||
"preview": "yarn exec vitepress preview"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
40
blocksuite/docs-site/pages-worker.mjs
Normal file
40
blocksuite/docs-site/pages-worker.mjs
Normal file
@@ -0,0 +1,40 @@
|
||||
const canonicalHost = 'blocksuite.io';
|
||||
const redirectHosts = new Set([
|
||||
'blocksuite.affine.pro',
|
||||
'block-suite.com',
|
||||
'blocksite.dev',
|
||||
'blocksite.io',
|
||||
'blocksuit.dev',
|
||||
'blocksuit.io',
|
||||
]);
|
||||
const apiMemberPathPattern =
|
||||
/^\/api\/@blocksuite\/(.+)\/(classes|enumerations|functions|interfaces|type-aliases|variables)\/[^/]+\.html$/;
|
||||
|
||||
export default {
|
||||
fetch(request, env) {
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (redirectHosts.has(url.hostname)) {
|
||||
url.hostname = canonicalHost;
|
||||
url.protocol = 'https:';
|
||||
|
||||
return Response.redirect(url.toString(), 301);
|
||||
}
|
||||
|
||||
if (url.pathname === '/blocksuite-overview.html') {
|
||||
url.pathname = '/guide/overview.html';
|
||||
|
||||
return Response.redirect(url.toString(), 301);
|
||||
}
|
||||
|
||||
const apiMemberPath = url.pathname.match(apiMemberPathPattern);
|
||||
|
||||
if (apiMemberPath) {
|
||||
url.pathname = `/api/@blocksuite/${apiMemberPath[1]}.html`;
|
||||
|
||||
return Response.redirect(url.toString(), 301);
|
||||
}
|
||||
|
||||
return env.ASSETS.fetch(request);
|
||||
},
|
||||
};
|
||||
34
blocksuite/docs-site/typedoc-remove-inherited.mjs
Normal file
34
blocksuite/docs-site/typedoc-remove-inherited.mjs
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Converter } from 'typedoc';
|
||||
|
||||
export function load(app) {
|
||||
app.converter.on(Converter.EVENT_RESOLVE_END, context => {
|
||||
pruneInheritedReflections(context.project);
|
||||
});
|
||||
}
|
||||
|
||||
function pruneInheritedReflections(reflection) {
|
||||
if (reflection.children) {
|
||||
reflection.children = reflection.children.filter(
|
||||
child => !child.inheritedFrom
|
||||
);
|
||||
reflection.children.forEach(pruneInheritedReflections);
|
||||
}
|
||||
|
||||
if (reflection.groups) {
|
||||
reflection.groups = reflection.groups
|
||||
.map(group => ({
|
||||
...group,
|
||||
children: group.children.filter(child => !child.inheritedFrom),
|
||||
}))
|
||||
.filter(group => group.children.length > 0);
|
||||
}
|
||||
|
||||
if (reflection.categories) {
|
||||
reflection.categories = reflection.categories
|
||||
.map(category => ({
|
||||
...category,
|
||||
children: category.children.filter(child => !child.inheritedFrom),
|
||||
}))
|
||||
.filter(category => category.children.length > 0);
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,13 @@
|
||||
"packageOptions": {
|
||||
"includeVersion": true,
|
||||
"readme": "none",
|
||||
"disableSources": true,
|
||||
"excludeInternal": true,
|
||||
"excludeExternals": true,
|
||||
"externalPattern": ["node_modules/**/*"],
|
||||
"entryPoints": ["src/index.ts"]
|
||||
},
|
||||
"plugin": ["typedoc-plugin-markdown"],
|
||||
"plugin": ["typedoc-plugin-markdown", "./typedoc-remove-inherited.mjs"],
|
||||
"out": "./api",
|
||||
"entryPointStrategy": "packages",
|
||||
"includeVersion": false,
|
||||
@@ -22,8 +24,10 @@
|
||||
"readme": "none",
|
||||
"name": "BlockSuite API Documentation",
|
||||
"entryFileName": "index.md",
|
||||
"outputFileStrategy": "members",
|
||||
"outputFileStrategy": "modules",
|
||||
"hidePageHeader": true,
|
||||
"disableSources": true,
|
||||
"excludeInternal": true,
|
||||
"excludePrivate": true,
|
||||
"excludeProtected": true,
|
||||
"excludeExternals": true,
|
||||
|
||||
Reference in New Issue
Block a user