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

Update Post Slug while Draft on Title Changes #6631

Merged
merged 1 commit into from Mar 29, 2016
Merged

Update Post Slug while Draft on Title Changes #6631

merged 1 commit into from Mar 29, 2016

Conversation

dbalders
Copy link
Member

Closes #5062

  • As long as the post has never been published, update the slug to
    match the new title if the title is changed

draft-slug

@@ -139,9 +139,10 @@ Post = ghostBookshelf.Model.extend({
}
}

if (this.hasChanged('slug') || !this.get('slug')) {
// If the status is not published and has never been published (published at never been set), update slug with title
if (this.get('status') === 'draft' && !this.get('published_at')) {

This comment was marked as abuse.

@kevinansfield
Copy link
Contributor

I haven't tested it yet but it looks as though when a user manually changes the slug before publishing then those changes are overwritten and a new slug based on the title is used instead?

My understanding of the solution for #5062 was to only overwrite the slug if the user hasn't manually changed it by comparing the slug against the output from the title->slug generator.

@dbalders
Copy link
Member Author

ahh, ya forgot about that, thanks

Closes #5062

* As long as the post has never been published, update the slug to
match the new title if the title is changed
@dbalders
Copy link
Member Author

should be good to go now

@acburdine
Copy link
Member

LGTM and works well 👍

@ErisDS
Copy link
Member

ErisDS commented Mar 29, 2016

I think the model logic here is looking good to merge. Just wondering though - should there be a frontend piece to go with this?

E.g. on title changes if the post is a draft, resend the slug request? This would let the slug update in the background without a save, as autosaves are not triggered by the title field.

@ErisDS ErisDS merged commit 48b846b into TryGhost:master Mar 29, 2016
vickychijwani added a commit to vickychijwani/quill that referenced this pull request Aug 22, 2016
This is similar to Ghost's in-built slug update logic since 0.8.0
(see TryGhost/Ghost#6631), with some differences:

- The slug is updated even if a post is unpublished and then published
  again with a new title

- The slug is only updated on publish, not on every save

- If a custom slug was set on the draft, it will be overridden upon
  publishing

Refs: #122, #130
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.

None yet

4 participants