feat: public API, SEO and existing surfaces
This commit is contained in:
1 parent
45fbbc33b1
commit
c390fcfe8d
103 files changed
+4476
-231
No files matched your search
@@ -0,0 +1,22 @@
|
||||
package site
|
||||
|
||||
import "strings"
|
||||
|
||||
func (s Site) PublicURL(lang string, slug string) *string {
|
||||
if s.PublicURLPattern == nil || lang == "" {
|
||||
return nil
|
||||
}
|
||||
filled := strings.NewReplacer(LangPlaceholder, lang, SlugPlaceholder, slug).Replace(*s.PublicURLPattern)
|
||||
return &filled
|
||||
}
|
||||
|
||||
func (s Site) ArticleURL(lang string, slug string) (string, bool) {
|
||||
if localized := s.PublicURL(lang, slug); localized != nil {
|
||||
return *localized, true
|
||||
}
|
||||
return s.LegacyURL(slug), false
|
||||
}
|
||||
|
||||
func (s Site) LegacyURL(slug string) string {
|
||||
return s.BaseURL + "/" + slug
|
||||
}
|
||||
Reference in new issue
Block a user