-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reader: Add utils for user profile (#98346)
* Lookup user id if username is in route * 💫 UPDATE: reader author avatar links to use user profiles if flag is enabled * 🔨 REFACTOR: migrate PostTrackback to functional component with TS support * Revert "Lookup user id if username is in route" This reverts commit ac9f207. * ➕ ADDS: getUserProfileUrl util function * ➕ ADDS: isUserProfileEnabled util function * ➕ ADDS: getUserProfileBasePath util function --------- Co-authored-by: DustyReagan <[email protected]>
- Loading branch information
1 parent
06fa126
commit 54ee862
Showing
9 changed files
with
70 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import config from '@automattic/calypso-config'; | ||
|
||
/** | ||
* Return `true` if the user profile feature is enabled. | ||
*/ | ||
export function isUserProfileEnabled(): boolean { | ||
return config.isEnabled( 'reader/user-profile' ); | ||
} | ||
|
||
/** | ||
* Return the URL of the user profile page for a given user ID. | ||
* | ||
* Example: `/read/users/123` | ||
*/ | ||
export function getUserProfileUrl( userId: number ): string { | ||
return `/read/users/${ userId }`; | ||
} | ||
|
||
type UserProfileSubPage = '' | 'lists'; | ||
|
||
/** | ||
* Return the base path of the user profile page. | ||
*/ | ||
export function getUserProfileBasePath( subPage: UserProfileSubPage = '' ): string { | ||
return subPage ? `/read/users/:user_id/${ subPage }` : `/read/users/:user_id`; | ||
} |