Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(doc-core): support extendPageData hook & last updated time #3480

Merged
merged 5 commits into from Apr 19, 2023

Conversation

sanyuan0704
Copy link
Collaborator

@sanyuan0704 sanyuan0704 commented Apr 18, 2023

Summary

  1. 新增 extendPageData 钩子实现
  2. 实现 lastUpdated 插件
  3. 新增 lastUpdated 相关的主题配置

🤖 Generated by Copilot at 010d696

This pull request introduces several improvements and new features to the doc-core package, which is responsible for generating and rendering documentation pages. It simplifies and refactors the plugin handling, the data structures, and the components, making the code more concise, consistent, and reusable. It also adds the last updated time feature, which shows the modification date of each page, and enhances the search feature, which generates language-specific index files. Additionally, it updates the type definitions, the dependencies, and the changelog for the package.

Details

🤖 Generated by Copilot at 010d696

  • Add a markdown file to the .changeset directory for changelog and version updates (link)
  • Add a dependency to the @modern-js/doc-plugin-last-updated package in the doc-core package for the last updated time feature (link)
  • Simplify the build and dev functions in the doc-core package by removing the docPlugins parameter and using the getPlugins function instead (link, link, link, link, link)
  • Modify the hooks module in the doc-core package to import the @modern-js/doc-plugin-last-updated package and the PageIndexInfo type, define the getPlugins function, and add the extendPageData hook for each plugin (link, link, link, link, link)
  • Change the import source of the BuilderPlugin type from @modern-js/builder-webpack-provider to @modern-js/builder in the runtimeModule module in the doc-core package (link)
  • Modify the siteData module in the doc-core package to categorize the pages by language, generate the search index files for each language, run the extendPageData hook for each page data object, and simplify the siteData object that is exported as a virtual module (link, link, link, link, link, link, link, link)
  • Change the structure of the pageData object that is returned by the initPageData function in the App component in the doc-core package, and remove some redundant or unused properties (link)
  • Change the source of the language value from the data.lang property to the data.page.lang property in the useLang hook in the doc-core package (link)
  • Export the isEqualPath function from the @runtime module in the doc-core package, and use it to check if two paths are equivalent in the documentation context (link, link, link)
  • Add a new optional property to the DefaultThemeConfig and LocaleConfig interfaces in the doc-core package, which is the lastUpdated property, a boolean value that indicates whether to show the last updated time for each page in the documentation (link, link)
  • Change the structure of the PageData and SiteData interfaces in the doc-core package, and add a new type alias, which is the BaseRuntimePageInfo type, a subset of the PageIndexInfo type that omits the id, content, and domain properties (link, link, link)
  • Add a new optional property to the DocPlugin interface in the doc-core package, which is the extendPageData hook, a function that can modify or add properties to the PageIndexInfo object (link, link)
  • Modify the DocFooter component in the doc-core package to import the usePageData hook and get the last updated time of the current page (link)
  • Modify the HomeFeature and HomeHero components in the doc-core package to get the frontmatter data from a prop instead of the usePageData hook, to make them more reusable and decoupled from the runtime context (link, link, link, link)
  • Modify the Nav component in the doc-core package to change the source of the language value and remove the unnecessary ! operator (link, link)
  • Modify the Overview component in the doc-core package to change the source of the routePath value, remove the unnecessary type assertion, and import the isEqualPath function from the @runtime module (link, link, link)
  • Modify the Search component in the doc-core package to change the source of the language value (link)

Related Issue

Checklist

  • I have added changeset via pnpm run change.
  • I have updated the documentation.
  • I have added tests to cover my changes.

@changeset-bot
Copy link

changeset-bot bot commented Apr 18, 2023

🦋 Changeset detected

Latest commit: f801e54

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 216 packages
Name Type
@modern-js/doc-tools-doc Minor
@modern-js/utils Minor
@modern-js/doc-core Minor
@modern-js/babel-preset-app Minor
@modern-js/babel-preset-base Minor
@modern-js/babel-preset-lib Minor
@modern-js/core Minor
@modern-js/doc-plugin-auto-sidebar Minor
@modern-js/plugin-bff Minor
@modern-js/plugin-changeset Minor
@modern-js/plugin-data-loader Minor
@modern-js/plugin-i18n Minor
@modern-js/plugin-lint Minor
@modern-js/plugin-proxy Minor
@modern-js/plugin-ssg Minor
@modern-js/plugin-storybook Minor
@modern-js/plugin-swc Minor
@modern-js/plugin-tailwindcss Minor
@modern-js/plugin-garfish Minor
@modern-js/plugin-router-v5 Minor
@modern-js/runtime Minor
@modern-js/plugin-testing Minor
@modern-js/generator-common Patch
@modern-js/generator-plugin Patch
@modern-js/generator-utils Patch
@modern-js/new-action Minor
@modern-js/entry-generator Patch
@modern-js/repo-generator Patch
@modern-js/bff-core Minor
@modern-js/server-core Minor
@modern-js/create-request Minor
@modern-js/plugin-egg Minor
@modern-js/plugin-express Minor
@modern-js/plugin-koa Minor
@modern-js/plugin-nest Minor
@modern-js/plugin-polyfill Minor
@modern-js/plugin-server Minor
@modern-js/plugin-worker Minor
@modern-js/prod-server Minor
@modern-js/server Minor
@modern-js/server-utils Minor
@modern-js/builder-rspack-provider Minor
@modern-js/builder-shared Minor
@modern-js/builder-webpack-provider Minor
@modern-js/builder Minor
@modern-js/builder-plugin-esbuild Minor
@modern-js/builder-plugin-image-compress Minor
@modern-js/builder-plugin-node-polyfill Minor
@modern-js/builder-plugin-stylus Minor
@modern-js/builder-plugin-swc-base Minor
@modern-js/builder-plugin-swc Minor
@modern-js/plugin-module-doc Minor
@modern-js/app-tools Minor
@modern-js/doc-tools Minor
@modern-js/module-tools Minor
@modern-js/monorepo-tools Minor
@modern-js/create Minor
@modern-js/e2e Minor
@modern-js/node-bundle-require Minor
@modern-js/upgrade Minor
@modern-js/babel-compiler Minor
@scripts/vitest-config Minor
tests Minor
server-config Minor
@e2e/builder-plugin-import Minor
@e2e/builder Minor
@modern-js-app/eslint-config Minor
@modern-js/main-doc Minor
@modern-js/module-tools-docs Minor
api-service-koa Minor
bff-express Minor
bff-koa Minor
@modern-js/bff-generator Patch
@modern-js/dependence-generator Patch
@modern-js/doc-generator Patch
@modern-js/generator-generator Patch
@modern-js/module-generator Patch
@modern-js/module-test-generator Patch
@modern-js/monorepo-generator Patch
@modern-js/mwa-generator Patch
@modern-js/router-v5-generator Patch
@modern-js/rspack-generator Patch
@modern-js/ssg-generator Patch
@modern-js/storybook-generator Patch
@modern-js/test-generator Patch
@modern-js/upgrade-generator Patch
@modern-js/generator-plugin-plugin Patch
ssg-fixtures-simple Minor
ssg-fixtures-web-server Minor
tmp Minor
swc-minify-css Minor
swc-minify-js Minor
transform-fail Minor
integration-tailwindcss-v2 Minor
integration-tailwindcss-v3 Minor
twin-macro-v2 Minor
twin-macro-v3 Minor
@cypress-test/garfish-dashboard-router-v6 Minor
@cypress-test/garfish-dashboard Minor
@cypress-test/garfish-main-router-v6 Minor
@cypress-test/garfish-main Minor
@cypress-test/garfish-table Minor
app-docmuent Minor
file-based-router Minor
@integration-test/alias-set Minor
async-entry-test Minor
builder-rspack-with-ssr Minor
builder-rspack Minor
basic-module Minor
composes-basic Minor
composes-external Minor
dev-module Minor
diff-suffix-module Minor
global-module Minor
prod-module Minor
css Minor
antd-less Minor
bad-nested-npm-import Minor
bad-npm-import Minor
base-import Minor
css-ts-declaration Minor
disable-source-map Minor
exclude-less Minor
exclude-sass Minor
import-common-css Minor
inline-css-url Minor
keep-css-url Minor
less-import Minor
less-inline-js Minor
less-npm-import Minor
multi-css Minor
multi-less Minor
multi-sass Minor
nested-npm-import Minor
npm-import Minor
single-css Minor
single-less Minor
single-sass Minor
tips-to-install-less-plugin Minor
css-modules Minor
integration-custom-render Minor
integration-custom-template Minor
legacy-esbuild-minify-js Minor
esbuild-transform-and-minify Minor
always-inline Minor
always-url Minor
assets-in-css Minor
inline-limit Minor
routes Minor
use-loader Minor
select-entry-test Minor
server-middleware Minor
server-hook-reqeust Minor
server-hook-response Minor
server-hook-router Minor
@integration-test/server-hook-reqeust Minor
server-prod Minor
ssr-base-json-test Minor
ssr-base-test Minor
init Minor
ssr-streaming-test Minor
testing-app Minor
worker-test Minor
@modern-js/base-generator Patch
@modern-js/packages-generator Patch
@modern-js/server-generator Patch
@modern-js/tailwindcss-generator Patch
@scripts/update-codesmith Minor
webpack-builder-test Minor
@e2e/webpack-builder-image-compress Minor
@e2e/webpack-builder-css-modules Minor
integration-dev-asset-prefix Minor
integration-register-builder-plugins Minor
integration-copy-public-html Minor
integration-config-async-config-test Minor
integration-basic-local-config Minor
integration-config-function-params Minor
integration-local-config-function Minor
@modern-js/builder-doc Minor
simple-doc-template Minor
i18n-doc Minor
@modern-js/plugin-module-babel Minor
@modern-js/plugin-module-banner Minor
@modern-js/plugin-module-import Minor
@modern-js/plugin-module-main-fields Minor
@modern-js/plugin-module-node-polyfill Minor
@modern-js/plugin-module-polyfill Minor
@modern-js/plugin-module-target Minor
@modern-js/remark-container Minor
integration-module-doc Minor
@modern-js/eslint-config Minor
@modern-js/generator-cases Patch
@modern-js/changeset-generator Patch
@modern-js/tsconfig Minor
@modern-js/bff-runtime Minor
@modern-js/plugin Minor
@modern-js/types Minor
@scripts/build Minor
@scripts/check-changeset Minor
@scripts/codemod Minor
@scripts/jest-config Minor
@scripts/lint-package-json Minor
@scripts/prebundle Minor
integration-asset-prefix Minor
integration-builder-plugins Minor
integration-copy-assets Minor
doc-tools Minor
esbuild-integration Minor
integration-load-config Minor
runtime Minor
ssg Minor
ssr Minor
swc-integration Minor
@e2e/webpack-builder-import-antd-v4 Minor
@e2e/webpack-builder-import-antd-v5 Minor
@e2e/webpack-builder-node-polyfill Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Patch coverage: 76.04% and project coverage change: +0.60 🎉

Comparison is base (99693f0) 57.59% compared to head (f801e54) 58.20%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3480      +/-   ##
==========================================
+ Coverage   57.59%   58.20%   +0.60%     
==========================================
  Files         672      667       -5     
  Lines       17794    17669     -125     
  Branches     3876     3833      -43     
==========================================
+ Hits        10249    10284      +35     
+ Misses       6934     6780     -154     
+ Partials      611      605       -6     
Impacted Files Coverage Δ
packages/cli/core/src/nodeApi.ts 0.00% <ø> (ø)
packages/cli/core/src/createCli.ts 72.00% <72.00%> (ø)
packages/cli/core/src/config/loadConfig.ts 83.33% <85.71%> (+0.25%) ⬆️
packages/cli/core/src/utils/initAppDir.ts 88.88% <88.88%> (ø)
packages/cli/core/src/index.ts 71.42% <100.00%> (-0.62%) ⬇️
packages/cli/core/src/types/index.ts 100.00% <100.00%> (ø)
packages/cli/core/src/utils/index.ts 100.00% <100.00%> (ø)

... and 94 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sanyuan0704 sanyuan0704 merged commit 16399fd into main Apr 19, 2023
7 checks passed
@sanyuan0704 sanyuan0704 deleted the feat/doc-last-updated branch April 19, 2023 03:09
JSerFeng pushed a commit that referenced this pull request Apr 19, 2023
)

* feat: support extendPageData hook and last updated time

* chore: update CHANGELOG

* feat: move the last updated plugin to doc-core
This was referenced Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants