Skip to content

Commit

Permalink
refactor: load text data from self in markdown loader (#1881)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc committed Sep 11, 2023
1 parent 2dcc72a commit ed76ee6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/loaders/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,14 @@ function emitDefault(
.map((item) => `import ${item.specifier} from '${item.source}';`)
.join('\n')}
import React from 'react';
${
isTabContent
? `import { useTabMeta } from 'dumi';`
: `import { DumiPage, useRouteMeta } from 'dumi';`
}
${isTabContent ? `` : `import { DumiPage } from 'dumi';`}
import { texts as ${CONTENT_TEXTS_OBJ_NAME} } from '${winPath(
this.resourcePath,
)}?type=text';
// export named function for fastRefresh
// ref: https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#edits-always-lead-to-full-reload
function DumiMarkdownContent() {
const { texts: ${CONTENT_TEXTS_OBJ_NAME} } = use${
isTabContent ? 'TabMeta' : 'RouteMeta'
}();
return ${isTabContent ? ret.content : `<DumiPage>${ret.content}</DumiPage>`};
}
Expand Down

0 comments on commit ed76ee6

Please sign in to comment.