Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
files index
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Cheong committed Aug 31, 2023
1 parent bf583e0 commit ff4b03f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions api/handlers/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,19 @@ func GetPublishedFile(c *gin.Context) {
})
return
}
// Return file []byte
c.Data(200, "text/markdown; charset=utf-8", []byte(file))
c.String(200, file)
}
func GetSiteIndex(c *gin.Context) {
slug := c.Param("slug")
site, err := publish.GetSlug(slug)
if err != nil {
c.JSON(404,gin.H{"error":err.Error()})
return
}
files, err := publish.GetFiles(site.ID)
if err != nil {
c.JSON(500,gin.H{"error":err.Error()})
return
}
c.JSON(200, files)
}
1 change: 1 addition & 0 deletions cmd/obsidian-sync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func main() {
publishGroup.POST("delete", handlers.DeleteSite)

router.GET("/published/:slug/*path", handlers.GetPublishedFile)
router.GET("/published/:slug", handlers.GetSiteIndex)

router.GET("/", handlers.WsHandler)
router.GET("/ws", handlers.WsHandler)
Expand Down

0 comments on commit ff4b03f

Please sign in to comment.