@fullstackdatasolutions/articles 1.2.2 → 1.2.3

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.
package/dist/server.js CHANGED
@@ -95,8 +95,7 @@ function reportArticlesError(report) {
95
95
  articlesErrorHandler(report);
96
96
  }
97
97
 
98
- // src/markdown.ts
99
- var DEFAULT_LINK_TARGET_STRATEGY = "external-new-tab";
98
+ // src/linkClassification.ts
100
99
  function isNonBrowserNavigationLink(href) {
101
100
  return /^[a-zA-Z][a-zA-Z\d+.-]*:/.test(href) && !href.startsWith("http://") && !href.startsWith("https://");
102
101
  }
@@ -114,6 +113,9 @@ function isExternalHttpLink(href, siteUrl) {
114
113
  if (!siteOrigin) return true;
115
114
  return getOrigin(href) !== siteOrigin;
116
115
  }
116
+
117
+ // src/markdown.ts
118
+ var DEFAULT_LINK_TARGET_STRATEGY = "external-new-tab";
117
119
  function shouldOpenInNewTab(href, options = {}) {
118
120
  var _a;
119
121
  if (!href || href.startsWith("#") || isNonBrowserNavigationLink(href)) return false;
@@ -1512,6 +1514,7 @@ function getArticleSitemapEntries(baseUrlOrConfig) {
1512
1514
 
1513
1515
  // src/renderMdx.tsx
1514
1516
  import React from "react";
1517
+ import Link from "next/link";
1515
1518
  import * as devRuntime from "react/jsx-dev-runtime";
1516
1519
  import * as runtime from "react/jsx-runtime";
1517
1520
  import { evaluate } from "@mdx-js/mdx";
@@ -1527,6 +1530,19 @@ function makeImgComponent(basePath) {
1527
1530
  return React.createElement("img", __spreadValues({ src: resolvedSrc, alt }, props));
1528
1531
  };
1529
1532
  }
1533
+ function isInternalNavigableHref(href, siteUrl) {
1534
+ if (!href || href.startsWith("#") || isNonBrowserNavigationLink(href)) return false;
1535
+ return !isExternalHttpLink(href, siteUrl);
1536
+ }
1537
+ function makeLinkComponent(siteUrl) {
1538
+ return function MdxLink(_a) {
1539
+ var _b = _a, { href, children } = _b, props = __objRest(_b, ["href", "children"]);
1540
+ if (typeof href === "string" && isInternalNavigableHref(href, siteUrl)) {
1541
+ return React.createElement(Link, __spreadValues({ href }, props), children);
1542
+ }
1543
+ return /* @__PURE__ */ jsx("a", __spreadProps(__spreadValues({ href }, props), { children }));
1544
+ };
1545
+ }
1530
1546
  function renderMdxSource(source, basePath, config) {
1531
1547
  return __async(this, null, function* () {
1532
1548
  const isDevelopment = process.env.NODE_ENV === "development";
@@ -1541,8 +1557,10 @@ function renderMdxSource(source, basePath, config) {
1541
1557
  ]
1542
1558
  }));
1543
1559
  const Content = mdxModule.default;
1544
- const internalComponents = basePath ? { img: makeImgComponent(basePath) } : void 0;
1545
- const components = internalComponents || (config == null ? void 0 : config.mdxComponents) ? __spreadValues(__spreadValues({}, internalComponents), config == null ? void 0 : config.mdxComponents) : void 0;
1560
+ const internalComponents = __spreadValues({
1561
+ a: makeLinkComponent(config == null ? void 0 : config.siteUrl)
1562
+ }, basePath ? { img: makeImgComponent(basePath) } : {});
1563
+ const components = __spreadValues(__spreadValues({}, internalComponents), config == null ? void 0 : config.mdxComponents);
1546
1564
  return /* @__PURE__ */ jsx(Content, { components });
1547
1565
  });
1548
1566
  }