Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions public_configs/fast-pr-url-rules.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ const urlRules = [
domains: ['open-digger.cn', 'open-digger'],
ruleFunction: (url) => {
const baseUrl = 'https://open-digger.cn/';
if (!url.startsWith(baseUrl)) return null;
const repoName = 'X-lab2017/open-digger-website';
const branch = 'master';
const platform = 'Github';
const horizontalRatio=0.95;
const verticalRatio=0.5;
const urlObj = new URL(url);
let docPath = urlObj.pathname.slice(1);
let filePath = '';
if (!url.startsWith(baseUrl)) return null;
let i18n = null;
let docPath = url.replace(baseUrl, '').split('#')[0];
for (const l of ['en/', 'fr/']) {
if (docPath.startsWith(l)) {
i18n = l;
Expand All @@ -21,13 +22,25 @@ const urlRules = [
}
if (docPath.startsWith('docs/')) {
docPath = docPath.substring('docs/'.length);
if (docPath.endsWith('metrics/playground')) {
// playground can not be edited
return null;
}
filePath = `${i18n != null ? `i18n/${i18n}docusaurus-plugin-content-docs/current/` : 'docs/'}${docPath}.md`;
} else if (docPath.startsWith('blog/')) {
filePath = `${i18n != null ? `i18n/${i18n}docusaurus-plugin-content-` : ''}${docPath}/index.mdx`;
} else {
// not blog and docs
return null;
}
return { filePath, repoName, branch, platform,horizontalRatio,verticalRatio };
return { filePath, repoName, branch, platform, horizontalRatio, verticalRatio };
},
tests: [
[
// front page
'https://open-digger.cn/',
undefined,
],
[
// docs
'https://open-digger.cn/docs/user_docs/label_data',
Expand Down Expand Up @@ -67,7 +80,7 @@ const urlRules = [
if (!url.startsWith(baseUrl)) return null;
const docPath = url.replace(baseUrl, '').split('#')[0];
const filePath = `docs/textbook/${docPath.slice(0, -1)}.md`;
return { filePath, repoName, branch, platform,horizontalRatio,verticalRatio };
return { filePath, repoName, branch, platform, horizontalRatio, verticalRatio };
},
},
{
Expand All @@ -82,7 +95,7 @@ const urlRules = [
if (!url.startsWith(baseUrl)) return null;
const docPath = url.replace(baseUrl, '').split('#')[0];
const filePath = `docs/textbooks/${docPath}index.md`;
return { filePath, repoName, branch, platform,horizontalRatio,verticalRatio };
return { filePath, repoName, branch, platform, horizontalRatio, verticalRatio };
},
},
{
Expand All @@ -99,7 +112,7 @@ const urlRules = [
if (docPath.startsWith('slide')) return null;
docPath = docPath.replace('.html', '');
const filePath = `src/${docPath}.md`;
return { filePath, repoName, branch, platform,horizontalRatio,verticalRatio };
return { filePath, repoName, branch, platform, horizontalRatio, verticalRatio };
},
tests: [
['https://kaiyuanshe.github.io/oss-book/Enterprise-and-Open-Source.html', 'src/Enterprise-and-Open-Source.md'],
Expand All @@ -115,12 +128,12 @@ const urlRules = [
expired: () => new Date().getTime() > new Date('2025-01-01 00:00:00').getTime(),
ruleFunction: (url) => {
const baseUrl = 'https://www.kaiwudb.com/kaiwudb_docs/#/';
if (!url.startsWith(baseUrl)) return null;
const repoName = 'kwdb/docs';
let branch = 'master';
const platform = 'Gitee';
const horizontalRatio=0.95;
const verticalRatio=0.95;
if (!url.startsWith(baseUrl)) return null;
let docPath = url.replace(baseUrl, '').split('#')[0].replace('.html', '');
function extractVersion(str) {
const pattern = /^oss_v(\d+(\.\d+)*)\/.*$/;
Expand All @@ -139,10 +152,12 @@ const urlRules = [
if (version !== null) {
branch = version;
docPath = docPath.slice(version.length + 6);
} else {
return null;
}
}
const filePath = `${docPath}.md`;
return { filePath, repoName, branch, platform,horizontalRatio,verticalRatio };
return { filePath, repoName, branch, platform, horizontalRatio, verticalRatio };
},
tests: [
[
Expand Down