Skip to content

Commit 06bf13d

Browse files
committed
Fix checking metadata of imported poem
1 parent 48594d3 commit 06bf13d

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/Toolbox/Consistency/CustomPageChecker.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ public void VerifyPoemOfSkyCategoryStartingWithSpecificWordsIsListedOnCustomPage
2222
Root data)
2323
{
2424
var errors = new List<string>();
25-
if (importedPoem is not null && !importedPoem.Categories.SelectMany(c => c.SubCategories).Contains("Ciel"))
26-
return;
25+
if (importedPoem is not null)
26+
{
27+
if (!importedPoem.Categories.SelectMany(c => c.SubCategories).Contains("Ciel"))
28+
return;
29+
if (!importedPoem.Paragraphs.First().Verses.First().StartsWith("Le ciel est ")
30+
&& !importedPoem.Paragraphs.First().Verses.First().StartsWith("Les cieux sont "))
31+
return;
32+
}
2733

2834
var rootDir = Path.Combine(Directory.GetCurrentDirectory(), configuration[Constants.CONTENT_ROOT_DIR]!);
2935
var pageFile = Path.Combine(rootDir, "..", "categories", "ciel", "_index.md");
@@ -38,23 +44,22 @@ public void VerifyPoemOfSkyCategoryStartingWithSpecificWordsIsListedOnCustomPage
3844

3945
foreach (var poem in poems)
4046
{
41-
var seasonId = poem.SeasonId;
42-
var poemFileName = poem.Id.Substring(0, poem.Id.LastIndexOf('_'));
43-
var regexp = new Regex($"(../../seasons/{seasonId}\\w*/{poemFileName})");
44-
var match = regexp.Match(pageContent);
45-
if (match.Success) continue;
46-
4747
// When starting with "Le ciel est gris" or "Les cieux sont gris" they are listed on special repeats custom listing
4848
if (poem.Paragraphs.First().Verses.First().StartsWith("Le ciel est gris"))
4949
continue;
5050
if (poem.Paragraphs.First().Verses.First().StartsWith("Les cieux sont gris"))
5151
continue;
52+
53+
var seasonId = poem.SeasonId;
54+
var poemFileName = poem.Id.Substring(0, poem.Id.LastIndexOf('_'));
55+
var regexp = new Regex($"(../../seasons/{seasonId}\\w*/{poemFileName})");
56+
var match = regexp.Match(pageContent);
57+
if (match.Success) continue;
5258

5359
errors.Add($"Poem {poem.Id} should be listed on 'Ciel' category index page!");
54-
55-
if (errors.Any())
56-
throw new CustomPageConsistencyException(errors);
5760
}
61+
if (errors.Any())
62+
throw new CustomPageConsistencyException(errors);
5863
}
5964

6065
/// <summary>

0 commit comments

Comments
 (0)