Fix series name for themes with a character subdir but no variant

Three layout depths exist under definitions/:
  series/file.json              (e.g. Megumin)
  series/character/file.json    (e.g. Rem, Ram, Beatrice, Miku)
  series/character/variant/file.json  (most themes)

Counting from the end of the path produced wrong series names for the
middle case. Always read the series as the first directory after
'definitions/' instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-22 17:49:50 +00:00
parent bfcc21fb27
commit 000599e191
+5 -2
View File
@@ -47,8 +47,11 @@ export function loadTheme(definitionPath: string, dokiRepoRoot: string): ThemeCo
const variant = hasVariant ? nameParts[nameParts.length - 1] : null;
// Series directory is 4 levels up when a variant dir exists, 2 levels up otherwise
const series = hasVariant ? parts[parts.length - 4] : parts[parts.length - 2];
// Series is always the first directory after 'definitions/' regardless of depth.
// Counting from the end is fragile because definitions can be 2, 3 or 4 segments
// deep (series/file, series/char/file, series/char/variant/file).
const defsIdx = parts.lastIndexOf('definitions');
const series = parts[defsIdx + 1];
const internalName = ['doki', sanitize(series), sanitize(def.displayName), variant ? sanitize(variant) : null]
.filter(Boolean)