本文整理汇总了Golang中github.com/spf13/hugo/hugolib.Site类的典型用法代码示例。如果您正苦于以下问题:Golang Site类的具体用法?Golang Site怎么用?Golang Site使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Site类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: check
func check(cmd *cobra.Command, args []string) error {
if err := InitializeConfig(checkCmd); err != nil {
return err
}
site := hugolib.Site{}
return site.Analyze()
}
示例2: init
"github.com/spf13/hugo/hugolib"
"syscall"
)
func init() {
check.AddCommand(limit)
}
var check = &cobra.Command{
Use: "check",
Short: "Check content in the source directory",
Long: `Hugo will perform some basic analysis on the
content provided and will give feedback.`,
Run: func(cmd *cobra.Command, args []string) {
InitializeConfig()
site := hugolib.Site{Config: *Config}
site.Analyze()
},
}
var limit = &cobra.Command{
Use: "ulimit",
Short: "Check system ulimit settings",
Long: `Hugo will inspect the current ulimit settings on the system.
This is primarily to ensure that Hugo can watch enough files on some OSs`,
Run: func(cmd *cobra.Command, args []string) {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
fmt.Println("Error Getting Rlimit ", err)
}
示例3: main
func main() {
flag.Usage = usage
flag.Parse()
if *help {
usage()
}
if *version {
fmt.Println("Hugo Static Site Generator v0.8")
return
}
config := hugolib.SetupConfig(cfgfile, source)
config.BuildDrafts = *draft
config.UglyUrls = *uglyUrls
config.Verbose = *verbose
if *baseUrl != "" {
config.BaseUrl = *baseUrl
} else if *server {
config.BaseUrl = "http://localhost:" + *port
}
if *destination != "" {
config.PublishDir = *destination
}
if *cpuprofile != 0 {
f, err := os.Create("/tmp/hugo-cpuprofile")
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
for i := 0; i < *cpuprofile; i++ {
_, _ = buildSite(config)
}
}
// Copy Static to Destination first
err := fsync.SyncDel(config.GetAbsPath(config.PublishDir+"/"), config.GetAbsPath(config.StaticDir+"/"))
if err != nil {
log.Fatalf("Error copying static files to %s: %v", config.GetAbsPath(config.PublishDir), err)
}
if *checkMode {
site := hugolib.Site{Config: *config}
site.Analyze()
os.Exit(0)
}
if *watchMode {
fmt.Println("Watching for changes. Press ctrl+c to stop")
_, err = buildSite(config)
if err != nil {
fmt.Println(err)
return
}
err := NewWatcher(config, *port, *server)
if err != nil {
fmt.Println(err)
}
}
if _, err = buildSite(config); err != nil {
fmt.Println(err)
}
if *server {
serve(*port, config)
}
}