@@ -120,15 +120,20 @@ func (pp *PathParser) parse(component, s string) (*Path, error) {
120120 return p , nil
121121}
122122
123- func (pp * PathParser ) parseIdentifier (component , s string , p * Path , i , lastDot , numDots int ) {
123+ func (pp * PathParser ) parseIdentifier (component , s string , p * Path , i , lastDot , numDots int , isLast bool ) {
124124 if p .posContainerHigh != - 1 {
125125 return
126126 }
127127 mayHaveLang := numDots > 1 && p .posIdentifierLanguage == - 1 && pp .LanguageIndex != nil
128128 mayHaveLang = mayHaveLang && (component == files .ComponentFolderContent || component == files .ComponentFolderLayouts )
129129 mayHaveOutputFormat := component == files .ComponentFolderLayouts
130130 mayHaveKind := p .posIdentifierKind == - 1 && mayHaveOutputFormat
131- mayHaveLayout := component == files .ComponentFolderLayouts
131+ var mayHaveLayout bool
132+ if p .pathType == TypeShortcode {
133+ mayHaveLayout = ! isLast && component == files .ComponentFolderLayouts
134+ } else {
135+ mayHaveLayout = component == files .ComponentFolderLayouts
136+ }
132137
133138 var found bool
134139 var high int
@@ -235,19 +240,22 @@ func (pp *PathParser) doParse(component, s string, p *Path) (*Path, error) {
235240 lastDot := 0
236241 lastSlashIdx := strings .LastIndex (s , "/" )
237242 numDots := strings .Count (s [lastSlashIdx + 1 :], "." )
243+ if strings .Contains (s , "/_shortcodes/" ) {
244+ p .pathType = TypeShortcode
245+ }
238246
239247 for i := len (s ) - 1 ; i >= 0 ; i -- {
240248 c := s [i ]
241249
242250 switch c {
243251 case '.' :
244- pp .parseIdentifier (component , s , p , i , lastDot , numDots )
252+ pp .parseIdentifier (component , s , p , i , lastDot , numDots , false )
245253 lastDot = i
246254 case '/' :
247255 slashCount ++
248256 if p .posContainerHigh == - 1 {
249257 if lastDot > 0 {
250- pp .parseIdentifier (component , s , p , i , lastDot , numDots )
258+ pp .parseIdentifier (component , s , p , i , lastDot , numDots , true )
251259 }
252260 p .posContainerHigh = i + 1
253261 } else if p .posContainerLow == - 1 {
@@ -283,10 +291,9 @@ func (pp *PathParser) doParse(component, s string, p *Path) (*Path, error) {
283291 p .pathType = TypeContentData
284292 }
285293 }
286-
287294 }
288295
289- if component == files .ComponentFolderLayouts {
296+ if p . pathType < TypeMarkup && component == files .ComponentFolderLayouts {
290297 if p .posIdentifierBaseof != - 1 {
291298 p .pathType = TypeBaseof
292299 } else {
@@ -302,12 +309,10 @@ func (pp *PathParser) doParse(component, s string, p *Path) (*Path, error) {
302309 }
303310
304311 if p .pathType == TypeShortcode && p .posIdentifierLayout != - 1 {
305- // myshortcode or myshortcode.html, no layout.
306- if len (p .identifiersKnown ) <= 2 {
312+ id := p .identifiersKnown [p .posIdentifierLayout ]
313+ if id .Low == p .posContainerHigh {
314+ // First identifier is shortcode name.
307315 p .posIdentifierLayout = - 1
308- } else {
309- // First is always the name.
310- p .posIdentifierLayout --
311316 }
312317 }
313318
0 commit comments