diff --git a/broker.go b/broker.go index f878fad..5c7c8e5 100644 --- a/broker.go +++ b/broker.go @@ -56,6 +56,11 @@ func (b *broker) FetchRemoteEntries(published, drafts bool) ([]*entry, error) { } return nil, err } + if b.rootURL != "" { + if l := feed.Links.Find("alternate"); l != nil { + b.rootURL = l.Href + } + } for _, ae := range feed.Entries { e, err := entryFromAtom(&ae) diff --git a/config.go b/config.go index aff3020..8e68498 100644 --- a/config.go +++ b/config.go @@ -45,6 +45,7 @@ type blogConfig struct { OmitDomain *bool `yaml:"omit_domain"` Owner string `yaml:"owner"` local bool + rootURL string } func (bc *blogConfig) localRoot() string { @@ -55,6 +56,22 @@ func (bc *blogConfig) localRoot() string { return filepath.Join(paths...) } +func (bc *blogConfig) fetchRootURL() string { + if bc.rootURL != "" { + return bc.rootURL + } + b := newBroker(bc) + u := entryEndPointUrl(bc) + feed, err := b.Client.GetFeed(u) + if err != nil { + return "" + } + if l := feed.Links.Find("alternate"); l != nil { + b.rootURL = l.Href + } + return b.rootURL +} + func loadConfig(r io.Reader, fpath string) (*config, error) { bytes, err := io.ReadAll(r) if err != nil {