Skip to content

Commit

Permalink
docs: correct logic for sync umi docs (#1398)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript committed Dec 29, 2022
1 parent daf46fa commit 86ec97c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/sync-from-umi.js
Expand Up @@ -3,12 +3,32 @@ const path = require('path');
const https = require('https');

const UMI_DOC_DIR = path.join(__dirname, '..', 'docs', '.upstream');
const REPLACE_MESSAGE_MDX = [
// remove mdx component import statements
{ type: 'replace', value: [/^[^\r\n]+ from 'umi';\n*/, ''] },
// replace Message component
{
type: 'replace',
value: [
/<Message(?: type="[^"]+")? emoji="(?:🚨|⚠️)">([^]+?)<\/Message>/,
':::warning$1:::',
],
},
{
type: 'replace',
value: [
/<Message(?: type="[^"]+")? emoji="(💡|🚀)">([^]+?)<\/Message>/,
':::info$1:::',
],
},
];
const FILE_LIST = [
// config docs
{
localname: 'config.md',
upstream: 'https://cdn.jsdelivr.net/gh/umijs/umi@4/docs/docs/api/config.md',
actions: [
...REPLACE_MESSAGE_MDX,
// remove head content
{ type: 'slice', value: [2] },
// remove unnecessary option
Expand Down Expand Up @@ -78,6 +98,7 @@ const FILE_LIST = [
localname: 'api.md',
upstream: 'https://cdn.jsdelivr.net/gh/umijs/umi@4/docs/docs/api/api.md',
actions: [
...REPLACE_MESSAGE_MDX,
// remove head content
{ type: 'slice', value: [6] },
{ type: 'replace', value: ['{\n/*\n', ''] },
Expand All @@ -102,6 +123,7 @@ const FILE_LIST = [
upstream:
'https://cdn.jsdelivr.net/gh/umijs/umi@4/docs/docs/guides/plugins.md',
actions: [
...REPLACE_MESSAGE_MDX,
// remove head content
{ type: 'slice', value: [1] },
{ type: 'replace', value: ['Umi 的核心就在于它的插件机制。', ''] },
Expand Down

0 comments on commit 86ec97c

Please sign in to comment.