Browse Source

Refactor slug doc

Raven 1 year ago
parent
commit
4a75b451b9

File diff suppressed because it is too large
+ 0 - 0
docs/search_indexes.json


+ 4 - 2
docs/seo.html

@@ -209,7 +209,7 @@
 <h2><a name="usage" class="anchor" href="#usage" rel="nofollow" aria-hidden="true"><span class="octicon octicon-link"></span></a>
 Usage</h2>
 
-<p>Initialize a <code>Collection</code> instance and register global seo configuration. The <code>Collection</code> manages SEO of all the registered models and hold global seo settings</p>
+<p>Initialize a <code>Collection</code> instance. The <code>Collection</code> manages all the registered models and hold global seo settings</p>
 
 <div class="highlight highlight-go"><pre>collection := seo.NewCollection()
 
@@ -259,6 +259,8 @@ Register customized variables</h3>
 <h3><a name="register-setting-variable" class="anchor" href="#register-setting-variable" rel="nofollow" aria-hidden="true"><span class="octicon octicon-link"></span></a>
 Register setting variable</h3>
 
+<p>This variable will be saved in the database and available as a global variable while editing SEO settings.</p>
+
 <div class="highlight highlight-go"><pre>collection.RegisterSEO(&amp;Product{}).RegisterSettingVaribles(struct{ProductTag string}{})
 </pre></div>
 <h3><a name="render-seo-html-data" class="anchor" href="#render-seo-html-data" rel="nofollow" aria-hidden="true"><span class="octicon octicon-link"></span></a>
@@ -284,7 +286,7 @@ Customization</h2>
 <highlightjs :language='"go"' :code='"var SeoCollection *seo.Collection\n\nfunc ConfigureSeo(b *presets.Builder, db *gorm.DB) {\n\tSeoCollection = seo.NewCollection()\n\tSeoCollection.RegisterSEO(\u0026models.Post{}).RegisterContextVariables(\n\t\t\"Title\",\n\t\tfunc(object interface{}, _ *seo.Setting, _ *http.Request) string {\n\t\t\tif article, ok := object.(models.Post); ok {\n\t\t\t\treturn article.Title\n\t\t\t}\n\t\t\treturn \"\"\n\t\t},\n\t).RegisterSettingVaribles(struct{ Test string }{})\n\tSeoCollection.RegisterSEOByNames(\"Not Found\", \"Internal Server Error\")\n\tSeoCollection.Configure(b, db)\n}\n"'></highlightjs>
 <h2><a name="definition" class="anchor" href="#definition" rel="nofollow" aria-hidden="true"><span class="octicon octicon-link"></span></a>Definition</h2>
 
-<p><code>Collection</code> manages SEO of all the registered models and hold global seo settings.</p>
+<p><code>Collection</code> manages all the registered models and hold global seo settings.</p>
 
 <highlightjs :language='"go"' :code='"type Collection struct {\n\tregisteredSEO []*SEO\n\tglobalName    string      //default name is GlobalSEO\n\tinherited     bool        //default is true. the order is model seo setting, system seo setting, global seo setting\n\tdbContextKey  interface{} // get db from context\n\tsettingModel  interface{} // db model\n}\n"'></highlightjs>
 <p><code>SEO</code> provides system-level default page matadata.</p>

+ 2 - 2
docs/slug.html

@@ -205,11 +205,11 @@
 <div id='docMainBox' class='px-16 pb-12 pt-4 overflow-auto'>
 <h1 class='mb-8'>Slug</h1>
 
-<div class='border-t'><p>Slug provides an easy way to create a pretty URL for your model.</p>
+<div class='border-t'><p>Slug provides an easy way to create pretty URLs for your model.</p>
 <h2><a name="usage" class="anchor" href="#usage" rel="nofollow" aria-hidden="true"><span class="octicon octicon-link"></span></a>
 Usage</h2>
 
-<p>Use <code>slug.Slug</code> as your field type with the same name as the benefactor field, from which the slug&#39;s value should be dynamically derived, and prepended with <code>WithSlug</code>, for example:</p>
+<p>If the source field called <code>Name</code>, then use <code>*WithSlug</code> which is <code>NameWithSlug</code> as the slug field name, the field type should be <code>slug.Slug</code></p>
 
 <div class="highlight highlight-go"><pre>
 type User struct {

+ 2 - 0
docsrc/content/basics/seo.go

@@ -61,6 +61,8 @@ collection.RegisterSEO(&Product{}).
 ~~~
 
 ### Register setting variable
+This variable will be saved in the database and available as a global variable while editing SEO settings.
+
 ~~~go
 collection.RegisterSEO(&Product{}).RegisterSettingVaribles(struct{ProductTag string}{})
 ~~~

+ 0 - 22
docsrc/content/basics/sitemap.go

@@ -1,22 +0,0 @@
-package basics
-
-import (
-	. "github.com/theplant/docgo"
-)
-
-var Slug = Doc(
-	Markdown(`
-Slug provides an easy way to create a pretty URL for your model.
-## Usage
-
-Use ~~~slug.Slug~~~ as your field type with the same name as the benefactor field, from which the slug's value should be dynamically derived, and prepended with ~~~WithSlug~~~, for example:
-~~~go
-
-type User struct {
-	gorm.Model
-	Name            string
-	NameWithSlug    slug.Slug
-}
-~~~
-`),
-).Title("Slug")

+ 22 - 0
docsrc/content/basics/slug.go

@@ -0,0 +1,22 @@
+package basics
+
+import (
+	. "github.com/theplant/docgo"
+)
+
+var Slug = Doc(
+	Markdown(`
+Slug provides an easy way to create pretty URLs for your model.
+## Usage
+
+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.
+~~~go
+
+type User struct {
+	gorm.Model
+	Name            string
+	NameWithSlug    slug.Slug
+}
+~~~
+`),
+).Title("Slug")

Some files were not shown because too many files changed in this diff