Skip to content

Commit

Permalink
Canonical logic upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak committed Jul 29, 2024
1 parent a899965 commit d48ca55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@forge42/seo-tools",
"version": "1.2.0",
"version": "1.2.1",
"private": false,
"keywords": ["seo", "remix-seo", "seo-tools", "structured-data", "sitemap", "robots", "canonical", "seo-alternate"],
"description": "Set of helpers designed to help you create, maintain and develop your SEO",
"description": "Framework agnostic set of helpers designed to help you create, maintain and develop your SEO",
"scripts": {
"test": "vitest run",
"test:cov": "vitest run --coverage",
Expand Down
7 changes: 6 additions & 1 deletion src/canonical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export interface CanonicalLinkOptions<U> {
* @example "/some-page"
*/
url: string
/**
* The canonical url of the current page
* @example "https://example.com/some-page"
*/
canonicalUrl?: string
/**
* Object containing the attributes to be added to the canonical link tag
* @example {rel: "canonical", href: "https://example.com/some-page"}
Expand Down Expand Up @@ -79,7 +84,7 @@ export const generateCanonicalLinks = <U, T extends boolean>(
): T extends true ? CanonicalLink[] : string => {
const { urlTransformer, alternatives, domain, canonicalAttributes, url, altAttributesTransformer } = options
const generatedCanonicalAttributes = canonicalAttributes ? convertObjectToString(canonicalAttributes) : ""
const canonicalUrl = `${domain + url}`
const canonicalUrl = options.canonicalUrl ?? `${domain + url}`
if (asJson) {
return [
{
Expand Down

0 comments on commit d48ca55

Please sign in to comment.