Get author by username/slug

You can use this code for create author page.

// packages/my-package/index.js
const profilePage = {
	name: 'profile',
	priority: 1,
	pattern: '/profile/:user',
	func: async ({
		state,
		link,
		params,
		libraries,
		force,
	}) => {
		const response = await libraries.source.api.get({
			endpoint: 'users',
			params: { slug: params.user },
		})
		const data = await response.json()
		state.source.data[link].isProfile = true
		state.source.data[link].author = isEmpty(data)
			? {}
			: data[0]
	},
}

export default  {
    .
    .
    .
    actions: {
		actions: {
			init: ({ libraries }) => {
				libraries.source.handlers.push(profilePage)
			},
		},
         ...
   }
}

Hi @Jay,

Thanks for sharing it.
Can you explain a bit more the purpose of this code? Could you share a codesandbox with this code in action so the community can see it live?