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

Fix showing page tree items without slug #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

djohalo2
Copy link
Member

@djohalo2 djohalo2 commented Jan 9, 2025

Currently if any page was added to the page tree and the user did not add a title/slug the page is not shown in the tree. Once you close the editor it is hard to find again and results in unused draft pages.

This fix shows these pages as untitled in the tree so that they can be updated or removed by users.

@djohalo2 djohalo2 requested a review from tstikvoort January 9, 2025 10:17
@djohalo2 djohalo2 added the bugfix label Jan 9, 2025
@@ -110,7 +110,7 @@ export const PageTreeViewItem = ({
onClick={onItemClick}>
<Flex align="center" gap={3}>
<UrlText isDisabled={isDisabled || (!page.isPublished && page.isDraft)} textOverflow="ellipsis">
{parentPath ? page.slug?.current : getRootPageSlug(page, config) ?? '/'}
{parentPath ? page.slug?.current ?? 'untitled' : getRootPageSlug(page, config) ?? '/'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that untitled is the right word here. Maybe fall back on title and otherwise untitled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never show the title in the page tree but always the slug, right? I chose untitled, because sanity does the same for documents that do not have a title-like field available. I feel like that consistency is nice here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants