Azuma Daisuke dc5e64f84c use @focus to fire seo.tagInputsFocus 1 ano atrás
..
v_seo 1542cdbc56 create a new component VSeo to support adding tag to seo section 3 anos atrás
README.md db162389ac add Readme file 3 anos atrás
admin.go dc5e64f84c use @focus to fire seo.tagInputsFocus 1 ano atrás
admin_test.go dbc469f449 fix seo test 1 ano atrás
collection.go 3c70220dd0 open graph title,description,meta data 1 ano atrás
collection_test.go 77bc5d1cc3 change function name 3 anos atrás
embed.go abd359076b fix organization name changed 2 anos atrás
helper_test.go f6ceb45b17 change test db 1 ano atrás
messages.go 3c70220dd0 open graph title,description,meta data 1 ano atrás
model.go 714416d8c0 fix test 1 ano atrás
model_test.go 714416d8c0 fix test 1 ano atrás
perm.go ce6bee9445 Add Permission and i18n to SEO 3 anos atrás
v_seo.go 1542cdbc56 create a new component VSeo to support adding tag to seo section 3 anos atrás

README.md

SEO

The SEO library allows for the management and injection of dynamic data into HTML tags for the purpose of Search Engine Optimisation.

Usage

  • Create a SEO collection

    // Create a collection and register global seo by default
    collection := seo.NewCollection()
    
    // Change the default global name
    collection.SetGlobalName("My Global SEO")
    
    // Change the default context db key
    collection.SetDBContextKey("My DB")
    
    // Change the default seo model setting
    type MySEOSetting struct{
    QorSEOSetting
    publish
    l10n
    }
    collection.SetSettingModel(&MySEOSetting{})
    
    // Turn off the default inherit the upper level SEO data when the current SEO data is missing
    collection.SetInherited(false)
    
    
  • Register and remove SEO

    // Register mutiple SEO by name
    collection.RegisterSEOByNames("Not Found", "Internal Server Error")
    
    // Register a SEO by model
    type Product struct{
    Name  string
    Setting Setting
    }
    collection.RegisterSEO(&Product{})
    
    // Remove a SEO
    collection.RemoveSEO(&Product{}).RemoveSEO("Not Found")
    
  • Configure SEO

    // Change the default SEO name when register a SEO by model
    
    collection.RegisterSEO(&Product{}).SetName("My Product")
    
    // Register a context Variable
    collection.RegisterSEO(&Product{}).
          RegisterContextVariables("og:image", func(obj interface{}, _ *Setting, _ *http.Request) string {
    						return obj.image.url
    					}).
          RegisterContextVariables("Name", func(obj interface{}, _ *Setting, _ *http.Request) string {
    						return obj.Name
    					})
    
    
    // Register setting variable
    collection.RegisterSEO(&Product{}).
          RegisterSettingVaribles(struct{ProductTag string}{})
    
  • Render SEO html data

    // Render Global SEO
    collection.RenderGlobal(request)
    
    // Render SEO by a name
    collection.Render("product", request)
    
    // Render SEO by a model
    collection.Render(Product{}, request)