@quartz-community/tag-page 1.0.1 → 1.0.2
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 +6 -0
- package/dist/components/index.js +5 -7
- package/dist/components/index.js.map +1 -1
- package/dist/index.js +12 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -271,8 +271,6 @@ function getDate(data) {
|
|
|
271
271
|
const dates = data.dates;
|
|
272
272
|
return dates?.[defaultDateType];
|
|
273
273
|
}
|
|
274
|
-
|
|
275
|
-
// node_modules/@quartz-community/utils/dist/path.js
|
|
276
274
|
function simplifySlug(fp) {
|
|
277
275
|
const res = stripSlashes(trimSuffix(fp, "index"), true);
|
|
278
276
|
return res.length === 0 ? "/" : res;
|
|
@@ -2816,12 +2814,12 @@ var TagContent_default = ((opts) => {
|
|
|
2816
2814
|
const TagContent = (props) => {
|
|
2817
2815
|
const { tree, fileData, allFiles, cfg } = props;
|
|
2818
2816
|
const fd = fileData;
|
|
2819
|
-
const
|
|
2817
|
+
const slug = fd.slug;
|
|
2820
2818
|
const locale = cfg?.locale ?? "en-US";
|
|
2821
|
-
if (!(
|
|
2822
|
-
throw new Error(`Component "TagContent" tried to render a non-tag page: ${
|
|
2819
|
+
if (!(slug?.startsWith("tags/") || slug === "tags")) {
|
|
2820
|
+
throw new Error(`Component "TagContent" tried to render a non-tag page: ${slug}`);
|
|
2823
2821
|
}
|
|
2824
|
-
let tag = simplifySlug(
|
|
2822
|
+
let tag = simplifySlug(slug.slice("tags/".length));
|
|
2825
2823
|
if (tag !== "/" && tag.endsWith("/")) tag = tag.slice(0, -1);
|
|
2826
2824
|
const allPagesWithTag = (t2) => allFiles.filter(isListed).filter(
|
|
2827
2825
|
(file) => (file.frontmatter?.tags ?? []).flatMap(getAllSegmentPrefixes).includes(t2)
|
|
@@ -2860,7 +2858,7 @@ var TagContent_default = ((opts) => {
|
|
|
2860
2858
|
const root2 = contentPage?.filePath ? contentPage?.htmlAst : void 0;
|
|
2861
2859
|
const tagDesc = !root2 || root2.children.length === 0 ? contentPage?.description : htmlToJsx(root2);
|
|
2862
2860
|
const tagListingPage = contentPage?.slug ?? tagPageSlug(t2, tags);
|
|
2863
|
-
const href = resolveRelative(
|
|
2861
|
+
const href = resolveRelative(slug, tagListingPage);
|
|
2864
2862
|
return /* @__PURE__ */ u2("div", { children: [
|
|
2865
2863
|
/* @__PURE__ */ u2("h2", { children: /* @__PURE__ */ u2("a", { class: "internal tag-link", href, children: t2 }) }),
|
|
2866
2864
|
tagDesc && /* @__PURE__ */ u2("p", { children: tagDesc }),
|
|
@@ -2903,8 +2901,8 @@ var TagContent_default = ((opts) => {
|
|
|
2903
2901
|
});
|
|
2904
2902
|
|
|
2905
2903
|
// src/pageType.ts
|
|
2906
|
-
var tagMatcher = ({ slug
|
|
2907
|
-
return
|
|
2904
|
+
var tagMatcher = ({ slug }) => {
|
|
2905
|
+
return slug.startsWith("tags/") || slug === "tags";
|
|
2908
2906
|
};
|
|
2909
2907
|
var TagPage = (opts) => ({
|
|
2910
2908
|
name: "TagPage",
|
|
@@ -2919,20 +2917,20 @@ var TagPage = (opts) => ({
|
|
|
2919
2917
|
tags.add("index");
|
|
2920
2918
|
const existingTagSlugs = /* @__PURE__ */ new Set();
|
|
2921
2919
|
for (const [, file] of content) {
|
|
2922
|
-
const
|
|
2923
|
-
if (
|
|
2924
|
-
existingTagSlugs.add(
|
|
2920
|
+
const slug = file.data?.slug;
|
|
2921
|
+
if (slug && slug.startsWith("tags/")) {
|
|
2922
|
+
existingTagSlugs.add(slug);
|
|
2925
2923
|
}
|
|
2926
2924
|
}
|
|
2927
2925
|
const virtualPages = [];
|
|
2928
2926
|
for (const tag of tags) {
|
|
2929
|
-
const
|
|
2927
|
+
const slug = tagPageSlug(tag, tags);
|
|
2930
2928
|
if (existingTagSlugs.has(joinSegments("tags", tag)) || existingTagSlugs.has(joinSegments("tags", tag, "index"))) {
|
|
2931
2929
|
continue;
|
|
2932
2930
|
}
|
|
2933
2931
|
const title = tag === "index" ? i18n(locale).pages.tagContent.tagIndex : opts?.prefixTags ? `${i18n(locale).pages.tagContent.tag}: ${tag}` : tag;
|
|
2934
2932
|
virtualPages.push({
|
|
2935
|
-
slug
|
|
2933
|
+
slug,
|
|
2936
2934
|
title,
|
|
2937
2935
|
data: {}
|
|
2938
2936
|
});
|