Skip to content
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

WIP: Set document title on route change #620

Closed
wants to merge 1 commit into from

Conversation

agubler
Copy link
Member

@agubler agubler commented Dec 21, 2019

Type: feature

The following has been addressed in the PR:

Description:

Adds support for setting the document.title on route change. This can be done either statically in the route configuration, a callback passed to the router to dynamically set the title or a combination of the two.

Statically:

routes.ts

export default [
    {
        path: 'foo/{param}?{queryParam}'
        outlet: 'foo',
        title: 'Foo Title'
    }
];

Dynamically on Router initialisation using the setDocumentTitle callback (using the injector registration as an example, but the same can be passed when instantiating a new Router directly):

registerRouterInjector(routes, registry, {
    setDocumentTitle: ({ title, outlet, params, queryParams }) => {
        if (outlet === 'dynamic-title-outlet') {
            return `${outlet}-${params.id}-${queryParams.bar}`;
        }
        return title;
    }
});

Currently the options interface for the setDocumentTitle look like:

export interface DocumentTitleOptions {
	title?: string;
	outlet: string;
	params: Params;
	queryParams: Params;
}

Resolves #601

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 21, 2019

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9a0eb5a:

Sandbox Source
lingering-currying-duxxt Configuration

@agubler
Copy link
Member Author

agubler commented Apr 9, 2020

superseded by #725

@agubler agubler closed this Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Router should be able to change the document.title
1 participant