Skip to content

Commit

Permalink
feat: support canonicalBaseURL
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinslin committed Aug 30, 2021
1 parent 5ba2a0f commit f64e97c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/common-all/src/dnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
SchemaProps,
SchemaPropsDict,
SchemaRaw,
SchemaTemplate
SchemaTemplate,
} from "./types";
import { getSlugger, isNotUndefined, randomColor } from "./utils";
import { genUUID } from "./uuid";
Expand Down
21 changes: 21 additions & 0 deletions packages/nextjs-template/components/DendronSEO.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ const getCanonicalUrl = ({
return [base, sitePath, suffix].join("");
};

const getCanonicalUrl = ({
sitePath,
seoProps,
siteConfig,
}: {
sitePath: string;
seoProps: NoteSEOProps;
siteConfig: DendronSiteConfig;
}): string => {
if (seoProps.canonicalBaseUrl) {
return [siteConfig.siteUrl, sitePath].join("");
}
if (seoProps.canonicalUrl) {
return seoProps.canonicalUrl;
}
const base = siteConfig.canonicalBaseUrl
? siteConfig.canonicalBaseUrl
: siteConfig.siteUrl;
return [base, sitePath].join("");
};

export default function DendronSEO() {
const dendronRouter = useDendronRouter();
const engine = useEngineAppSelector((state) => state.engine);
Expand Down

0 comments on commit f64e97c

Please sign in to comment.