18 lines
282 B
Go
18 lines
282 B
Go
package controllers
|
|
|
|
import (
|
|
"go_blog/models"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func Home(c *gin.Context) {
|
|
|
|
var items []models.Content
|
|
models.DB.Select("*").Limit(5).Find(&items, "type = ?", "post")
|
|
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
|
"Items": items,
|
|
})
|
|
}
|