code: func NewPermalinkExpander(ps *helpers.PathSpec) (PermalinkExpander, error) {
  
  	p := PermalinkExpander{ps: ps}
  
  	p.knownPermalinkAttributes = map[string]pageToPermaAttribute{
  		"year":        p.pageToPermalinkDate,
  		"month":       p.pageToPermalinkDate,
  		"monthname":   p.pageToPermalinkDate,
  		"day":         p.pageToPermalinkDate,
  		"weekday":     p.pageToPermalinkDate,
  		"weekdayname": p.pageToPermalinkDate,
  		"yearday":     p.pageToPermalinkDate,
  		"section":     p.pageToPermalinkSection,
  		"sections":    p.pageToPermalinkSections,
  		"title":       p.pageToPermalinkTitle,
  		"slug":        p.pageToPermalinkSlugElseTitle,
  		"filename":    p.pageToPermalinkFilename,
  	}
  
  	patterns := ps.Cfg.GetStringMapString("permalinks")
  	if patterns == nil {
  		return p, nil
  	}
  
  	e, err := p.parse(patterns)
  	if err != nil {
  		return p, err
  	}
  
  	p.expanders = e
  
  	return p, nil
  }
docs: // NewPermalinkExpander creates a new PermalinkExpander configured by the given
  // PathSpec.