czon 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ContentPage = void 0;
7
+ const node_path_1 = require("node:path");
7
8
  const react_1 = __importDefault(require("react"));
8
9
  const ContentMeta_1 = require("./components/ContentMeta");
9
10
  const CZONFooter_1 = require("./components/CZONFooter");
@@ -20,6 +21,9 @@ const ContentPage = props => {
20
21
  const tags = frontmatter.tags || [];
21
22
  const category = props.file.category;
22
23
  const relatedContents = props.ctx.site.files.filter(f => f.category === category && f.hash !== props.file.hash);
24
+ // 查找指向当前文章的其他文章
25
+ const thisPath = (0, node_path_1.resolve)('/', props.file.path);
26
+ const referencedFiles = props.ctx.site.files.filter(f => f.links.some(link => (0, node_path_1.resolve)('/', (0, node_path_1.dirname)(f.path), link) === thisPath));
23
27
  return (react_1.default.createElement("html", { lang: props.lang, style: { background: 'black', overflow: 'hidden' } },
24
28
  react_1.default.createElement("head", null,
25
29
  react_1.default.createElement("meta", { charSet: "UTF-8" }),
@@ -40,6 +44,13 @@ const ContentPage = props => {
40
44
  const theContent = props.ctx.contents.find(c => c.lang === props.lang && c.hash === f.hash);
41
45
  return (react_1.default.createElement("li", { key: f.hash },
42
46
  react_1.default.createElement("a", { href: `${f.metadata?.slug}.html` }, theContent?.frontmatter.title)));
47
+ })))),
48
+ referencedFiles.length > 0 && (react_1.default.createElement(react_1.default.Fragment, null,
49
+ react_1.default.createElement("h2", null, "Referenced By"),
50
+ react_1.default.createElement("ul", null, referencedFiles.map(f => {
51
+ const theContent = props.ctx.contents.find(c => c.lang === props.lang && c.hash === f.hash);
52
+ return (react_1.default.createElement("li", { key: f.hash },
53
+ react_1.default.createElement("a", { href: `${f.metadata?.slug}.html` }, theContent?.frontmatter.title)));
43
54
  }))))),
44
55
  react_1.default.createElement("footer", { className: "footer" },
45
56
  react_1.default.createElement(LanguageSwitcher_1.LanguageSwitcher, { ctx: props.ctx, lang: props.lang, file: props.file }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "czon",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "CZone - AI enhanced Markdown content engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",