@mannisto/astro-metadata 2.0.0-alpha.1 → 2.0.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mannisto/astro-metadata",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.2",
4
4
  "description": "Metadata for Astro: page tags, social cards, favicons, the web app manifest and structured data.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/lib/rules.js CHANGED
@@ -712,8 +712,37 @@ function indexedPages(pages) {
712
712
  })
713
713
  }
714
714
 
715
+ /**
716
+ * Returns true for a page with an hreflang link to the canonical URL of another page.
717
+ *
718
+ * @param {import("./rules").SitePage} page
719
+ * @param {import("./rules").SitePage} other
720
+ * @returns {boolean}
721
+ */
722
+ function linksTo(page, other) {
723
+ const url = findLink(other.head, "canonical")
724
+ if (!url) return false
725
+ return hreflangLinks(page.head).some((link) => {
726
+ return link.href === url
727
+ })
728
+ }
729
+
730
+ /**
731
+ * Returns true for two pages that are versions of one page in other locales:
732
+ * one of the pages has an hreflang link to the other.
733
+ *
734
+ * @param {import("./rules").SitePage} a
735
+ * @param {import("./rules").SitePage} b
736
+ * @returns {boolean}
737
+ */
738
+ function isLocaleVersion(a, b) {
739
+ return linksTo(a, b) || linksTo(b, a)
740
+ }
741
+
715
742
  /**
716
743
  * Returns a problem for each page with a value that other pages also have.
744
+ * The versions of a page in other locales can have the same value, e.g. the name of
745
+ * an artwork in its title, so they do not count.
717
746
  *
718
747
  * @param {import("./rules").SitePage[]} pages
719
748
  * @param {(page: import("./rules").SitePage) => string | undefined} valueOf
@@ -721,29 +750,27 @@ function indexedPages(pages) {
721
750
  * @returns {import("./rules").SiteProblem[]}
722
751
  */
723
752
  function duplicates(pages, valueOf, name) {
724
- /** @type {Map<string, string[]>} */
753
+ /** @type {Map<string, import("./rules").SitePage[]>} */
725
754
  const groups = new Map()
726
755
  for (const page of indexedPages(pages)) {
727
756
  const value = valueOf(page)
728
- if (value) groups.set(value, [...(groups.get(value) ?? []), page.path])
757
+ if (value) groups.set(value, [...(groups.get(value) ?? []), page])
729
758
  }
730
759
 
731
- return [...groups.values()]
732
- .filter((paths) => {
733
- return paths.length > 1
734
- })
735
- .flatMap((paths) => {
736
- return paths.map((path) => {
737
- const others = paths.filter((other) => {
738
- return other !== path
739
- })
740
- const list =
741
- others.length === 1
742
- ? others[0]
743
- : `${others[0]} and ${count(others.length - 1, "other page")}`
744
- return { path, message: `The ${name} is the same as on ${list}.` }
760
+ return [...groups.values()].flatMap((group) => {
761
+ return group.flatMap((page) => {
762
+ const others = group.filter((other) => {
763
+ return other !== page && !isLocaleVersion(page, other)
745
764
  })
765
+ if (others.length === 0) return []
766
+
767
+ const list =
768
+ others.length === 1
769
+ ? others[0].path
770
+ : `${others[0].path} and ${count(others.length - 1, "other page")}`
771
+ return [{ path: page.path, message: `The ${name} is the same as on ${list}.` }]
746
772
  })
773
+ })
747
774
  }
748
775
 
749
776
  /**
@@ -2,10 +2,14 @@
2
2
  box-sizing: border-box;
3
3
  }
4
4
 
5
+ /*
6
+ * The z-index of the Audit app window of Astro: above the site, e.g. a fixed navigation,
7
+ * and under the toolbar bar (2000000010). The toolbar element has no stacking context.
8
+ */
5
9
  .panel {
6
10
  position: fixed;
7
11
  inset: 0 0 0 auto;
8
- z-index: 1;
12
+ z-index: 2000000009;
9
13
  display: flex;
10
14
  flex-direction: column;
11
15
  width: var(--panel-width, 480px);