-
Notifications
You must be signed in to change notification settings - Fork 27k
docs(docs-infra): add canonical link to each adev page #56540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Deployed adev-preview for c74e306 to: https://ng-dev-previews-fw--pr-angular-angular-56540-adev-prev-s1fcuqn6.web.app Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt. |
9902b25 to
999ceaa
Compare
999ceaa to
c74e306
Compare
josephperrott
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| const pathWithoutFragment = this.normalizePath(absolutePath).split('#')[0]; | ||
| const fullPath = `${ANGULAR_DEV}/${pathWithoutFragment}`; | ||
| this.document.querySelector('link[rel=canonical]')?.setAttribute('href', fullPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the needed information can already be found with location.origin and location.pathname, both available on CSR/SSR.
Shouldn't it be enough to do as suggested? (this mean that you no longer need normalizePath)
This also rely on the real origin of the page instead of the hardcoded value, meaning that the canonical url will always match the real url, maybe that's not what you want?
Example: https://next.angular.dev/ and so on will be used for the canonical.
If that's not what you want, you can change this.document.location.origin to ANGULAR_DEV.
| const pathWithoutFragment = this.normalizePath(absolutePath).split('#')[0]; | |
| const fullPath = `${ANGULAR_DEV}/${pathWithoutFragment}`; | |
| this.document.querySelector('link[rel=canonical]')?.setAttribute('href', fullPath); | |
| const fullPath = this.document.location.origin + this.document.location.pathname; | |
| this.document.querySelector('link[rel=canonical]')?.setAttribute('href', fullPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're doing pre-rendering, the domain isn't known at build time afaik.
| * Information about the deployment of this application. | ||
| */ | ||
| @Injectable({providedIn: 'root'}) | ||
| export class HeaderService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: HeaderService feels a bit "generic", it could be header in term of html (h1, h2, etc), header in term of some header component, ....
What do you think about something a bit more specific like HtmlHeadService or something like that?
|
This PR was merged into the repository by commit e81abdb. The changes were merged into the following branches: main, 18.0.x |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.