diff --git a/docs/modules/ROOT/pages/quarkus-roq-plugins.adoc b/docs/modules/ROOT/pages/quarkus-roq-plugins.adoc index 653b142f..6ada62ac 100644 --- a/docs/modules/ROOT/pages/quarkus-roq-plugins.adoc +++ b/docs/modules/ROOT/pages/quarkus-roq-plugins.adoc @@ -90,4 +90,6 @@ aliases: [first-roq-article-ever] --- ---- -Now, when you access the URL `http://localhost:8081/first-roq-article-ever`, you will be redirected to the `2024-08-29-welcome-to-roq` blog post. \ No newline at end of file +Now, when you access the URL `http://localhost:8081/first-roq-article-ever`, you will be redirected to the `2024-08-29-welcome-to-roq` blog post. + +NOTE: you can use link templating in aliases \ No newline at end of file diff --git a/plugin/aliases/deployment/src/main/java/io/quarkiverse/roq/plugin/aliases/deployment/RoqPluginAliasesProcessor.java b/plugin/aliases/deployment/src/main/java/io/quarkiverse/roq/plugin/aliases/deployment/RoqPluginAliasesProcessor.java index 6528c74f..573a94ee 100644 --- a/plugin/aliases/deployment/src/main/java/io/quarkiverse/roq/plugin/aliases/deployment/RoqPluginAliasesProcessor.java +++ b/plugin/aliases/deployment/src/main/java/io/quarkiverse/roq/plugin/aliases/deployment/RoqPluginAliasesProcessor.java @@ -6,17 +6,19 @@ import java.util.Map; import java.util.Set; +import io.quarkiverse.roq.frontmatter.deployment.Link; import io.quarkiverse.roq.frontmatter.deployment.data.RoqFrontMatterTemplateBuildItem; +import io.quarkiverse.roq.frontmatter.runtime.RoqSiteConfig; import io.quarkiverse.roq.frontmatter.runtime.model.RoqUrl; import io.quarkiverse.roq.generator.deployment.items.SelectedPathBuildItem; import io.quarkiverse.roq.plugin.aliases.deployment.items.RoqFrontMatterAliasesBuildItem; import io.quarkiverse.roq.plugin.aliases.runtime.RoqFrontMatterAliasesRecorder; -import io.quarkiverse.roq.util.PathUtils; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.vertx.http.deployment.HttpRootPathBuildItem; import io.quarkus.vertx.http.deployment.RouteBuildItem; import io.quarkus.vertx.http.deployment.devmode.NotFoundPageDisplayableEndpointBuildItem; import io.vertx.core.json.JsonArray; @@ -33,7 +35,9 @@ FeatureBuildItem feature() { } @BuildStep - public void consumeTemplates(List templates, + public void consumeTemplates( + RoqSiteConfig config, + List templates, BuildProducer aliasesProducer, BuildProducer selectedPathsProducer, BuildProducer notFoundPageDisplayableEndpointProducer) { @@ -55,7 +59,9 @@ public void consumeTemplates(List templates, } RoqUrl url = item.url(); for (String alias : aliasesName) { - aliasMap.put(alias, url.path()); + String aliasLink = Link.pageLink(config.rootPath(), alias, new Link.PageLinkData( + item.raw().info().baseFileName(), item.raw().info().date(), item.raw().collection(), item.data())); + aliasMap.put(aliasLink, url.path()); } } @@ -71,12 +77,14 @@ public void consumeTemplates(List templates, @BuildStep @Record(ExecutionTime.RUNTIME_INIT) - public void createVertxRedirects(RoqFrontMatterAliasesRecorder recorder, + public void createVertxRedirects( + HttpRootPathBuildItem httpRootPath, + RoqFrontMatterAliasesRecorder recorder, BuildProducer routes, List aliases) { for (RoqFrontMatterAliasesBuildItem item : aliases) { routes.produce(RouteBuildItem.builder() - .route(PathUtils.prefixWithSlash(item.alias())) + .route(httpRootPath.relativePath(item.alias())) .handler(recorder.addRedirect(item.target())) .build()); }