Skip to content

Commit

Permalink
feat(theme): bundle copyright2 as it as 0 deps comparing with theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Dec 30, 2023
1 parent e75649a commit 71c4e9e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/theme/src/guide/feature/copyright.md
Expand Up @@ -11,7 +11,7 @@ copy:
---

You may not want some of your articles to be copied by others, or you want copyright information appended to the clipboard when copying.
`vuepress-theme-hope` use <ProjectLink name="copyright2">vuepress-plugin-copyright2</ProjectLink> to provide this feature. To use it, install `vuepress-plugin-copyright2` manually in your project.
`vuepress-theme-hope` use <ProjectLink name="copyright2">vuepress-plugin-copyright2</ProjectLink> to provide this feature.

::: info

Expand Down
3 changes: 2 additions & 1 deletion docs/theme/src/zh/guide/feature/copyright.md
Expand Up @@ -11,7 +11,8 @@ copy:
---

你可能不想让你的某些文章被他人复制,或者你想版权信息在复制时自动附加。
`vuepress-theme-hope` 通过 <ProjectLink name="copyright2" path="/zh/">vuepress-plugin-copyright2</ProjectLink> 提供此功能。想要使用它,你需要在你的项目中手动安装 `vuepress-plugin-copyright2`

`vuepress-theme-hope` 通过 <ProjectLink name="copyright2" path="/zh/">vuepress-plugin-copyright2</ProjectLink> 提供此功能。

::: info

Expand Down
5 changes: 1 addition & 4 deletions packages/theme/package.json
Expand Up @@ -100,6 +100,7 @@
"vuepress-plugin-comment2": "workspace:*",
"vuepress-plugin-components": "workspace:*",
"vuepress-plugin-copy-code2": "workspace:*",
"vuepress-plugin-copyright2": "workspace:*",
"vuepress-plugin-md-enhance": "workspace:*",
"vuepress-plugin-photo-swipe": "workspace:*",
"vuepress-plugin-reading-time2": "workspace:*",
Expand All @@ -115,7 +116,6 @@
"nodejs-jieba": "^0.1.2",
"sass-loader": "^13.3.0",
"vuepress": "2.0.0-rc.0",
"vuepress-plugin-copyright2": "workspace:*",
"vuepress-plugin-feed2": "workspace:*",
"vuepress-plugin-pwa2": "workspace:*",
"vuepress-plugin-search-pro": "workspace:*",
Expand All @@ -138,9 +138,6 @@
"vuepress": {
"optional": true
},
"vuepress-plugin-copyright2": {
"optional": true
},
"vuepress-plugin-feed2": {
"optional": true
},
Expand Down
19 changes: 1 addition & 18 deletions packages/theme/src/node/plugins/copyright.ts
@@ -1,21 +1,12 @@
import type { Page, Plugin } from "@vuepress/core";
import { colors } from "@vuepress/utils";
import type { CopyrightOptions } from "vuepress-plugin-copyright2";
import { copyrightPlugin } from "vuepress-plugin-copyright2";
import { getAuthor, isPlainObject } from "vuepress-shared/node";

import type {
ThemeData,
ThemeNormalPageFrontmatter,
} from "../../shared/index.js";
import { logger } from "../utils.js";

let copyrightPlugin: (options: CopyrightOptions, legacy?: boolean) => Plugin;

try {
({ copyrightPlugin } = await import("vuepress-plugin-copyright2"));
} catch (e) {
// do nothing
}

/**
* @private
Expand All @@ -30,14 +21,6 @@ export const getCopyrightPlugin = (
): Plugin | null => {
if (!options) return null;

if (!copyrightPlugin) {
logger.error(
`${colors.cyan("vuepress-plugin-copyright2")} is not installed!`,
);

return null;
}

return copyrightPlugin(
<CopyrightOptions>{
canonical: hostname,
Expand Down

0 comments on commit 71c4e9e

Please sign in to comment.