slug.go 498 B

12345678910111213141516171819202122
  1. package basics
  2. import (
  3. . "github.com/theplant/docgo"
  4. )
  5. var Slug = Doc(
  6. Markdown(`
  7. Slug provides an easy way to create pretty URLs for your model.
  8. ## Usage
  9. If the source field called ~~Name~~, Use ~~*WithSlug~~ which is ~~NameWithSlug~~ as the slug field name, the field type should be ~~slug.Slug~~. Then the pretty URL would be derived from ~~Name~~ automatically on editing.
  10. ~~~go
  11. type User struct {
  12. gorm.Model
  13. Name string
  14. NameWithSlug slug.Slug
  15. }
  16. ~~~
  17. `),
  18. ).Title("Slug")