@riebeckite/plugin-taxonomy 0.0.22 → 0.0.24

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/index.js CHANGED
@@ -499,7 +499,6 @@ function buildDescription(term) {
499
499
  var TAXONOMY_PLUGIN_NAME = "taxonomy";
500
500
  function taxonomy(options = {}) {
501
501
  const resolved = resolveTaxonomyOptions(options);
502
- const emittedFeeds = /* @__PURE__ */ new Set();
503
502
  return definePlugin({
504
503
  name: TAXONOMY_PLUGIN_NAME,
505
504
  options,
@@ -509,7 +508,14 @@ function taxonomy(options = {}) {
509
508
  {
510
509
  id: "taxonomy-term",
511
510
  paths: ({ manifest }) => taxonomyPagePaths(manifest.discoverableEntries, resolved),
512
- outputDependencies: [{ type: "global" }],
511
+ outputDependencies: ({ manifest, pathname }) => {
512
+ const term = findTaxonomyTerm(
513
+ manifest.discoverableEntries,
514
+ resolved,
515
+ pathname
516
+ );
517
+ return term ? taxonomyPageOutputDependencies(term, resolved.related) : [{ type: "unknown" }];
518
+ },
513
519
  resolve: ({ manifest, pathname }) => {
514
520
  const term = findTaxonomyTerm(
515
521
  manifest.discoverableEntries,
@@ -530,7 +536,14 @@ function taxonomy(options = {}) {
530
536
  {
531
537
  id: "taxonomy-index",
532
538
  paths: () => taxonomyIndexPagePaths(resolved),
533
- outputDependencies: [{ type: "global" }],
539
+ outputDependencies: ({ pathname }) => {
540
+ const kind = resolveTaxonomyIndexPath(pathname, resolved);
541
+ const dependency = kind === "tag" ? { type: "projection", projection: "taxonomy-tags" } : kind === "folder" ? {
542
+ type: "projection",
543
+ projection: "taxonomy-folders"
544
+ } : void 0;
545
+ return dependency ? [...pageProjectionDependencies, dependency] : [{ type: "unknown" }];
546
+ },
534
547
  resolve: ({ manifest, pathname }) => {
535
548
  const kind = resolveTaxonomyIndexPath(pathname, resolved);
536
549
  if (!kind) return null;
@@ -552,24 +565,36 @@ function taxonomy(options = {}) {
552
565
  }
553
566
  }
554
567
  ],
555
- buildEnd(context) {
556
- const { config, manifest } = context;
557
- if (!config) return;
558
- const index = buildTaxonomyIndex(manifest.discoverableEntries, resolved);
568
+ planGeneratedOutputs(context) {
569
+ if (!context.site) return [];
570
+ const index = buildTaxonomyIndex(
571
+ context.manifest.discoverableEntries,
572
+ resolved
573
+ );
574
+ const outputs = [];
559
575
  for (const term of [...index.tags, ...index.folders]) {
560
576
  for (const format of enabledFormats(resolved)) {
561
577
  const path = feedFilePath(term.path, format);
562
- if (emittedFeeds.has(path)) continue;
563
- emittedFeeds.add(path);
564
- context.output.emit({
578
+ outputs.push({
565
579
  path,
566
- content: renderTermFeed(config, term, format, resolved.feedLimit),
567
- dependencies: [{ type: "global" }]
580
+ content: renderTermFeed(
581
+ { site: context.site },
582
+ term,
583
+ format,
584
+ resolved.feedLimit
585
+ ),
586
+ dependencies: taxonomyOutputDependencies(term)
568
587
  });
569
588
  }
570
589
  }
590
+ return outputs;
571
591
  },
572
- assets: [createStyleAsset(TAXONOMY_PLUGIN_NAME)]
592
+ assets: [
593
+ createStyleAsset(
594
+ TAXONOMY_PLUGIN_NAME,
595
+ "@riebeckite/plugin-taxonomy/style.css"
596
+ )
597
+ ]
573
598
  });
574
599
  }
575
600
  var taxonomyPlugin = taxonomy;
@@ -577,6 +602,23 @@ function taxonomyPagePaths(entries, options) {
577
602
  const index = buildTaxonomyIndex(entries, options);
578
603
  return [...index.tags, ...index.folders].map((term) => term.path);
579
604
  }
605
+ function taxonomyOutputDependencies(term) {
606
+ return [
607
+ term.kind === "tag" ? { type: "tag", tag: term.value } : { type: "folder", folder: term.value }
608
+ ];
609
+ }
610
+ function taxonomyPageOutputDependencies(term, related) {
611
+ const relatedDependencies = related && term.kind === "tag" ? [{ type: "projection", projection: "taxonomy-tags" }] : [];
612
+ return [
613
+ ...pageProjectionDependencies,
614
+ ...taxonomyOutputDependencies(term),
615
+ ...relatedDependencies
616
+ ];
617
+ }
618
+ var pageProjectionDependencies = [
619
+ { type: "projection", projection: "navigation" },
620
+ { type: "projection", projection: "recent-posts" }
621
+ ];
580
622
  function findTaxonomyTerm(entries, options, pathname) {
581
623
  const index = buildTaxonomyIndex(entries, options);
582
624
  return [...index.tags, ...index.folders].find(
@@ -5,6 +5,6 @@ import type { TaxonomyFeedFormat, TaxonomyHeadTag, TaxonomyTerm } from "./types.
5
5
  * link so a tag subscription is distinguishable from the site-wide feed that
6
6
  * `@riebeckite/plugin-seo` owns.
7
7
  */
8
- export declare function renderTermFeed(config: ResolvedRiebeckiteConfig, term: TaxonomyTerm, format: TaxonomyFeedFormat, limit?: number): string;
8
+ export declare function renderTermFeed(config: Pick<ResolvedRiebeckiteConfig, "site">, term: TaxonomyTerm, format: TaxonomyFeedFormat, limit?: number): string;
9
9
  /** Builds the `<link rel="alternate">` discovery tags for a term. */
10
10
  export declare function buildFeedHeadTags(term: TaxonomyTerm): TaxonomyHeadTag[];
package/dist/src/url.d.ts CHANGED
@@ -4,4 +4,4 @@ import type { ResolvedRiebeckiteConfig } from "@riebeckite/core";
4
4
  * SEO plugin's absolute-URL convention so taxonomy feeds and metadata match the
5
5
  * rest of the site without depending on the SEO package.
6
6
  */
7
- export declare function buildTaxonomyAbsoluteUrl(config: ResolvedRiebeckiteConfig, pathOrUrl: string): string;
7
+ export declare function buildTaxonomyAbsoluteUrl(config: Pick<ResolvedRiebeckiteConfig, "site">, pathOrUrl: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-taxonomy",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "./style.css": "./style.css"
16
16
  },
17
17
  "dependencies": {
18
- "@riebeckite/core": "0.0.22"
18
+ "@riebeckite/core": "0.0.24"
19
19
  },
20
20
  "devDependencies": {
21
21
  "tsx": "^4.22.4"