Skip to content

Commit af0ef47

Browse files
authored
Merge pull request #330 from wpengine/chore-fix-canonicals-remove-queries
Chore fix canonicals remove queries
2 parents 030bfa9 + 274cdba commit af0ef47

File tree

5 files changed

+5
-30
lines changed

5 files changed

+5
-30
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"shiki": "^3.2.1",
5656
"strip-markdown": "^6.0.0",
5757
"unified": "^11.0.5",
58-
"unist-util-visit": "^5.0.0",
5958
"vfile-matter": "^5.0.1"
6059
},
6160
"devDependencies": {

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/docs-layout.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,18 @@ export default function DocumentPage({
3939
}) {
4040
const flatRoutes = flattenRoutes(routes);
4141
const {
42-
asPath,
4342
query: { slug = [] },
4443
} = useRouter();
4544

45+
// Build the canonical path from slug
46+
const canonicalUrl = ["/docs", ...slug].join("/") + "/";
47+
4648
return (
4749
<>
4850
<Seo
4951
title={frontmatter?.title ?? "FALLBACK TITLE"}
5052
description={frontmatter?.description}
51-
url={asPath}
53+
url={canonicalUrl}
5254
/>
5355
<Disclosure
5456
as="div"

src/lib/remark-parsing.mjs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import withSmartQuotes from "remark-smartypants";
1313
import remarkStringify from "remark-stringify";
1414
import remarkStrip from "strip-markdown";
1515
import { unified } from "unified";
16-
import { visit } from "unist-util-visit";
1716
import { matter } from "vfile-matter";
1817
import { getRemoteImgUrl } from "./remote-mdx-files.mjs";
1918
/**
@@ -36,28 +35,6 @@ function addFrontmatterToVFile() {
3635
return (_, file) => matter(file);
3736
}
3837

39-
export function addTocToVFile() {
40-
return (tree, file) => {
41-
const toc = [];
42-
visit(tree, "element", (node) => {
43-
if (
44-
(node.tagName === "h2" || node.tagName === "h3") &&
45-
node.children[0].value
46-
) {
47-
const title = node.children[0]?.value;
48-
49-
toc.push({
50-
id: node.properties.id,
51-
text: title,
52-
level: Number.parseInt(node.tagName[1], 10),
53-
});
54-
}
55-
});
56-
57-
file.data.toc = toc;
58-
};
59-
}
60-
6138
/**
6239
* Returns the parsed content of a document from its markdown content.
6340
*

src/pages/docs/[[...slug]].jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function getStaticProps({ params }) {
1616
source,
1717
docsNavData,
1818
},
19-
revalidate: 1,
19+
revalidate: 600,
2020
};
2121
} catch (error) {
2222
if (error.notFound) {

0 commit comments

Comments
 (0)