Skip to content

Commit

Permalink
define isBlogEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Nov 12, 2023
1 parent 51ffbe0 commit 5531f68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (b *broker) LocalPath(e *entry) string {
}
localPath := e.URL.Path

if e.IsDraft && strings.Contains(e.EditURL, "/atom/entry/") {
if e.IsDraft && e.isBlogEntry() {
subdir, entryPath := extractEntryPath(e.URL.Path)
if entryPath == "" {
return ""
Expand Down Expand Up @@ -132,7 +132,7 @@ func (b *broker) StoreFresh(e *entry, path string) (bool, error) {
func (b *broker) Store(e *entry, path, origPath string) error {
logf("store", "%s", path)

if e.IsDraft && strings.Contains(e.EditURL, "/atom/entry/") {
if e.IsDraft && e.isBlogEntry() {
_, entryPath := extractEntryPath(e.URL.Path)
if entryPath == "" {
return fmt.Errorf("invalid path: %s", e.URL.Path)
Expand Down
8 changes: 8 additions & 0 deletions entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ func (eh *entryHeader) blogID() (string, error) {
return paths[4], nil
}

func (eh *entryHeader) isBlogEntry() bool {
return strings.Contains(eh.EditURL, "/atom/entry/")
}

func (eh *entryHeader) isStaticPage() bool {
return strings.Contains(eh.EditURL, "/atom/page/")
}

// Entry is an entry stored on remote blog providers
type entry struct {
*entryHeader
Expand Down

0 comments on commit 5531f68

Please sign in to comment.