@quartz-community/tag-page 1.0.0 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6977c9a: On the tag index, a tag with child tags and a hand-written `tags/<tag>.md` page links to that page instead of the virtual `tags/<tag>/` page it replaces, which was never emitted (a broken link).
8
+ - d1bec5e: Tags that have child tags (e.g. `kubernetes` with `kubernetes/k3s`) are now emitted as `tags/<tag>/index.html` instead of `tags/<tag>.html`, so the parent tag page is reachable on static hosts that resolve the `tags/<tag>/` directory first (jackyzha0/quartz#2556). Leaf tag URLs are unchanged.
9
+
3
10
  ## 1.0.0
4
11
 
5
12
  ### Major Changes
@@ -2800,6 +2800,19 @@ function i18n(locale) {
2800
2800
  return locales[locale] || en_US_default;
2801
2801
  }
2802
2802
 
2803
+ // src/util/tags.ts
2804
+ function hasChildTags(tag, allTags) {
2805
+ const prefix = `${tag}/`;
2806
+ for (const t2 of allTags) {
2807
+ if (t2.startsWith(prefix)) return true;
2808
+ }
2809
+ return false;
2810
+ }
2811
+ function tagPageSlug(tag, allTags) {
2812
+ if (tag === "index") return "tags/index";
2813
+ return hasChildTags(tag, allTags) ? joinSegments("tags", tag, "index") : joinSegments("tags", tag);
2814
+ }
2815
+
2803
2816
  // src/components/styles/listPage.scss
2804
2817
  var listPage_default = "ul.section-ul {\n list-style: none;\n margin-top: 2em;\n padding-left: 0;\n}\n\nli.section-li {\n margin-bottom: 1em;\n}\nli.section-li > .section {\n display: grid;\n grid-template-columns: fit-content(8em) 3fr 1fr;\n}\n@media all and (max-width: 600px) {\n li.section-li > .section > .tags {\n display: none;\n }\n}\nli.section-li > .section > .desc > h3 > a {\n background-color: transparent;\n}\nli.section-li > .section .meta {\n margin: 0 1em 0 0;\n opacity: 0.6;\n}\n\n.popover .section {\n grid-template-columns: fit-content(8em) 1fr !important;\n}\n.popover .section > .tags {\n display: none;\n}";
2805
2818
 
@@ -2824,7 +2837,8 @@ var TagContent_default = ((opts) => {
2824
2837
  if (!(slug2?.startsWith("tags/") || slug2 === "tags")) {
2825
2838
  throw new Error(`Component "TagContent" tried to render a non-tag page: ${slug2}`);
2826
2839
  }
2827
- const tag = simplifySlug(slug2.slice("tags/".length));
2840
+ let tag = simplifySlug(slug2.slice("tags/".length));
2841
+ if (tag !== "/" && tag.endsWith("/")) tag = tag.slice(0, -1);
2828
2842
  const allPagesWithTag = (t2) => allFiles.filter(isListed).filter(
2829
2843
  (file) => (file.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes).includes(t2)
2830
2844
  );
@@ -2857,11 +2871,11 @@ var TagContent_default = ((opts) => {
2857
2871
  sort: options?.sort
2858
2872
  });
2859
2873
  const contentPage = allFiles.find(
2860
- (file) => file.slug === `tags/${t2}`
2874
+ (file) => file.slug === `tags/${t2}` || file.slug === `tags/${t2}/index`
2861
2875
  );
2862
2876
  const root2 = contentPage?.filePath ? contentPage?.htmlAst : void 0;
2863
2877
  const tagDesc = !root2 || root2.children.length === 0 ? contentPage?.description : htmlToJsx(root2);
2864
- const tagListingPage = `/tags/${t2}`;
2878
+ const tagListingPage = contentPage?.slug ?? tagPageSlug(t2, tags);
2865
2879
  const href = resolveRelative(slug2, tagListingPage);
2866
2880
  return /* @__PURE__ */ u2("div", { children: [
2867
2881
  /* @__PURE__ */ u2("h2", { children: /* @__PURE__ */ u2("a", { class: "internal tag-link", href, children: t2 }) }),