@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 +7 -0
- package/dist/components/index.js +17 -3
- package/dist/components/index.js.map +1 -1
- package/dist/index.js +21 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -2784,6 +2784,19 @@ function i18n(locale) {
|
|
|
2784
2784
|
return locales[locale] || en_US_default;
|
|
2785
2785
|
}
|
|
2786
2786
|
|
|
2787
|
+
// src/util/tags.ts
|
|
2788
|
+
function hasChildTags(tag, allTags) {
|
|
2789
|
+
const prefix = `${tag}/`;
|
|
2790
|
+
for (const t2 of allTags) {
|
|
2791
|
+
if (t2.startsWith(prefix)) return true;
|
|
2792
|
+
}
|
|
2793
|
+
return false;
|
|
2794
|
+
}
|
|
2795
|
+
function tagPageSlug(tag, allTags) {
|
|
2796
|
+
if (tag === "index") return "tags/index";
|
|
2797
|
+
return hasChildTags(tag, allTags) ? joinSegments("tags", tag, "index") : joinSegments("tags", tag);
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2787
2800
|
// src/components/styles/listPage.scss
|
|
2788
2801
|
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}";
|
|
2789
2802
|
|
|
@@ -2808,7 +2821,8 @@ var TagContent_default = ((opts) => {
|
|
|
2808
2821
|
if (!(slug2?.startsWith("tags/") || slug2 === "tags")) {
|
|
2809
2822
|
throw new Error(`Component "TagContent" tried to render a non-tag page: ${slug2}`);
|
|
2810
2823
|
}
|
|
2811
|
-
|
|
2824
|
+
let tag = simplifySlug(slug2.slice("tags/".length));
|
|
2825
|
+
if (tag !== "/" && tag.endsWith("/")) tag = tag.slice(0, -1);
|
|
2812
2826
|
const allPagesWithTag = (t2) => allFiles.filter(isListed).filter(
|
|
2813
2827
|
(file) => (file.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes).includes(t2)
|
|
2814
2828
|
);
|
|
@@ -2841,11 +2855,11 @@ var TagContent_default = ((opts) => {
|
|
|
2841
2855
|
sort: options?.sort
|
|
2842
2856
|
});
|
|
2843
2857
|
const contentPage = allFiles.find(
|
|
2844
|
-
(file) => file.slug === `tags/${t2}`
|
|
2858
|
+
(file) => file.slug === `tags/${t2}` || file.slug === `tags/${t2}/index`
|
|
2845
2859
|
);
|
|
2846
2860
|
const root2 = contentPage?.filePath ? contentPage?.htmlAst : void 0;
|
|
2847
2861
|
const tagDesc = !root2 || root2.children.length === 0 ? contentPage?.description : htmlToJsx(root2);
|
|
2848
|
-
const tagListingPage =
|
|
2862
|
+
const tagListingPage = contentPage?.slug ?? tagPageSlug(t2, tags);
|
|
2849
2863
|
const href = resolveRelative(slug2, tagListingPage);
|
|
2850
2864
|
return /* @__PURE__ */ u2("div", { children: [
|
|
2851
2865
|
/* @__PURE__ */ u2("h2", { children: /* @__PURE__ */ u2("a", { class: "internal tag-link", href, children: t2 }) }),
|
|
@@ -2912,8 +2926,10 @@ var TagPage = (opts) => ({
|
|
|
2912
2926
|
}
|
|
2913
2927
|
const virtualPages = [];
|
|
2914
2928
|
for (const tag of tags) {
|
|
2915
|
-
const slug2 =
|
|
2916
|
-
if (existingTagSlugs.has(
|
|
2929
|
+
const slug2 = tagPageSlug(tag, tags);
|
|
2930
|
+
if (existingTagSlugs.has(joinSegments("tags", tag)) || existingTagSlugs.has(joinSegments("tags", tag, "index"))) {
|
|
2931
|
+
continue;
|
|
2932
|
+
}
|
|
2917
2933
|
const title = tag === "index" ? i18n(locale).pages.tagContent.tagIndex : opts?.prefixTags ? `${i18n(locale).pages.tagContent.tag}: ${tag}` : tag;
|
|
2918
2934
|
virtualPages.push({
|
|
2919
2935
|
slug: slug2,
|