11{{! Move to template code after fixing this issue:
2- https://github.com/google/mdbook-i18n-helpers/issues/70 }}
2+ https://github.com/google/mdbook-i18n-helpers/issues/70 }}
33<script >
4- (function () {
5- // See these pages for details:
6- // https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls
7- // https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics
8- let base = " https://rust-unofficial.github.io/patterns" ;
9- {{#if (eq language " en" )}}
10- let canonical_href = ` ${ base} /{{ path }}` ;
11- {{else }}
12- let canonical_href = ` ${ base} /{{ language }}/{{ path }}` ;
13- {{/ if }}
4+ (function () {
5+ // See these pages for details:
6+ // https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls
7+ // https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics
8+ let base = " https://rust-unofficial.github.io/patterns" ;
9+ {{#if (eq language " en" )}}
10+ let canonical_href = ` ${ base} /{{ path }}` ;
11+ {{else }}
12+ let canonical_href = ` ${ base} /{{ language }}/{{ path }}` ;
13+ {{/ if }}
1414
15- // mdbook gives us a string ending in ".md", we replace it with ".html":
16- canonical_href = canonical_href .slice (0 , - " md" .length ) + " html" ;
17- if (canonical_href .endsWith (" /index.html" )) {
18- canonical_href = canonical_href .slice (0 , - " index.html" .length );
19- }
15+ // mdbook gives us a string ending in ".md", we replace it with ".html":
16+ canonical_href = canonical_href .slice (0 , - " md" .length ) + " html" ;
17+ if (canonical_href .endsWith (" /index.html" )) {
18+ canonical_href = canonical_href .slice (0 , - " index.html" .length );
19+ }
2020
21- let link = document .createElement (" link" );
22- link .rel = " canonical" ;
23- link .href = canonical_href;
24- document .head .appendChild (link);
25- }) ()
26- </script >
21+ let link = document .createElement (" link" );
22+ link .rel = " canonical" ;
23+ link .href = canonical_href;
24+ document .head .appendChild (link);
25+ }) ()
26+ </script >
0 commit comments