當前位置: 首頁>>代碼示例>>Golang>>正文


Golang hugolib.Site類代碼示例

本文整理匯總了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()
}
開發者ID:mariuccio,項目名稱:hugo,代碼行數:8,代碼來源:check.go

示例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)
		}
開發者ID:jcdny,項目名稱:hugo,代碼行數:31,代碼來源:check.go

示例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)
	}

}
開發者ID:rawfalafel,項目名稱:hugo,代碼行數:78,代碼來源:main.go


注:本文中的github.com/spf13/hugo/hugolib.Site類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。