Skip to content

Commit

Permalink
Enable minisite to use a custom template when overriding left menu
Browse files Browse the repository at this point in the history
  • Loading branch information
rmannibucau committed Oct 13, 2022
1 parent 7e2c976 commit b53c478
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions minisite-core/src/main/java/io/yupiik/tools/minisite/MiniSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ protected String leftMenu(final Map<Page, Path> files) {
final Path output = configuration.getTarget();
return findIndexPages(files).map(it -> toMenuItem(output, it, itemTemplate)).collect(joining());
}
throw new IllegalArgumentException("Unknown key '" + key + "'");
try {
return findPageTemplate(templatesDir, key);
} catch (final RuntimeException re) {
throw new IllegalArgumentException("Unknown key '" + key + "'");
}
}).replace(template);
}

Expand Down Expand Up @@ -346,7 +350,11 @@ protected String generateIndex(final Map<Page, Path> htmls, final Function<Page,
case "content":
return indexContent;
default:
throw new IllegalArgumentException("Unknown key '" + key + "'");
try {
return findPageTemplate(templatesDir, key);
} catch (final RuntimeException re) {
throw new IllegalArgumentException("Unknown key '" + key + "'");
}
}
}).replace(contentTemplate))));

Expand Down Expand Up @@ -459,10 +467,14 @@ protected String getDefaultInterpolation(final String key, final Page page,
case "xyz": // passthrough
return "{{xyz}}";
default:
if (emptyIfMissing) {
return "";
try {
return findPageTemplate(getTemplatesDir(), key);
} catch (final RuntimeException re) {
if (emptyIfMissing) {
return "";
}
throw new IllegalArgumentException("Unknown template key '" + key + "'");
}
throw new IllegalArgumentException("Unknown template key '" + key + "'");
}
}

Expand Down

0 comments on commit b53c478

Please sign in to comment.