当前位置: 首页>>代码示例>>Golang>>正文


Golang helpers.GuessSection函数代码示例

本文整理汇总了Golang中github.com/spf13/hugo/helpers.GuessSection函数的典型用法代码示例。如果您正苦于以下问题:Golang GuessSection函数的具体用法?Golang GuessSection怎么用?Golang GuessSection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GuessSection函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: NewContent

func NewContent(cmd *cobra.Command, args []string) {
	InitializeConfig()

	if len(args) < 1 {
		cmd.Usage()
		jww.FATAL.Fatalln("path needs to be provided")
	}

	createpath := args[0]

	var kind string

	// assume the first directory is the section (kind)
	if strings.Contains(createpath[1:], "/") {
		kind = helpers.GuessSection(createpath)
	}

	if contentType != "" {
		kind = contentType
	}

	err := create.NewContent(kind, createpath)
	if err != nil {
		jww.ERROR.Println(err)
	}
}
开发者ID:vinchu,项目名称:hugo,代码行数:26,代码来源:new.go

示例2: Section

func (f *File) Section() string {
	if f.section != "" {
		return f.section
	}
	f.section = helpers.GuessSection(f.Dir())
	return f.section
}
开发者ID:dunn,项目名称:hugo,代码行数:7,代码来源:file.go

示例3: NewContent

// NewContent adds new content to a Hugo site.
func NewContent(cmd *cobra.Command, args []string) {
	InitializeConfig()

	if cmd.Flags().Lookup("format").Changed {
		viper.Set("MetaDataFormat", configFormat)
	}

	if len(args) < 1 {
		cmd.Usage()
		jww.FATAL.Fatalln("path needs to be provided")
	}

	createpath := args[0]

	var kind string

	// assume the first directory is the section (kind)
	if strings.Contains(createpath[1:], helpers.FilePathSeparator) {
		kind = helpers.GuessSection(createpath)
	}

	if contentType != "" {
		kind = contentType
	}

	err := create.NewContent(kind, createpath)
	if err != nil {
		jww.ERROR.Println(err)
	}
}
开发者ID:nurhavid,项目名称:hugo,代码行数:31,代码来源:new.go

示例4: newContentPathSection

func newContentPathSection(path string) (string, string) {
	// Forward slashes is used in all examples. Convert if needed.
	// Issue #1133
	createpath := strings.Replace(path, "/", helpers.FilePathSeparator, -1)
	var section string
	// assume the first directory is the section (kind)
	if strings.Contains(createpath[1:], helpers.FilePathSeparator) {
		section = helpers.GuessSection(createpath)
	}

	return createpath, section
}
开发者ID:maruel,项目名称:hugo,代码行数:12,代码来源:new.go

示例5: NewFile

func NewFile(relpath string) *File {
	f := &File{
		relpath: relpath,
	}

	f.dir, f.logicalName = filepath.Split(f.relpath)
	f.ext = strings.TrimPrefix(filepath.Ext(f.LogicalName()), ".")
	f.section = helpers.GuessSection(f.Dir())
	f.uniqueID = helpers.Md5String(f.LogicalName())

	return f
}
开发者ID:eRadical,项目名称:hugo,代码行数:12,代码来源:file.go

示例6: NewFile

// NewFile creates a new File pointer with the given relative path.
func NewFile(relpath string) *File {
	f := &File{
		relpath: relpath,
	}

	f.dir, f.logicalName = filepath.Split(f.relpath)
	f.ext = strings.TrimPrefix(filepath.Ext(f.LogicalName()), ".")
	f.baseName = helpers.Filename(f.LogicalName())

	f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".")
	if f.lang == "" {
		f.lang = viper.GetString("defaultContentLanguage")
	}
	f.translationBaseName = helpers.Filename(f.baseName)

	f.section = helpers.GuessSection(f.Dir())
	f.uniqueID = helpers.Md5String(f.LogicalName())

	return f
}
开发者ID:tubo028,项目名称:hugo,代码行数:21,代码来源:file.go

示例7: guessSection

func (p *Page) guessSection() {
	if p.Section == "" {
		p.Section = helpers.GuessSection(p.FileName)
	}
}
开发者ID:vinchu,项目名称:hugo,代码行数:5,代码来源:page.go


注:本文中的github.com/spf13/hugo/helpers.GuessSection函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。