Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
Arquivo: file.go Projeto: tubo028/hugo
// 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
}
Exemplo n.º 3
0
func (f *File) UniqueId() string {
	if f.uniqueId == "" {
		f.uniqueId = helpers.Md5String(f.LogicalName())
	}
	return f.uniqueId
}