<object type="application/kenticocloud" data-type="item" data-codename="my_tweet"></object>
link
parameter to get more information about the linked content items.
// Tip: Find more about Java SDK at https://kontent.ai/learn/java
public class TweetInlineContentItemsResolver extends InlineContentItemsResolver<Tweet> {
@Override
String resolve() {
return "<blockquote class=\"twitter-tweet\" data-lang=\"en\" data-theme=\"" + tweet.theme[0].codename + "\"><a href=\"" + tweet.tweetLink.url + "\"></a></blockquote>"
}
}
// Tip: Find more about Java SDK at https://kontent.ai/learn/java
DeliveryClient client = new DeliveryClient("<YOUR_ENVIRONMENT_ID>");
client.registerInlineContentItemsResolver(new TweetInlineContentItemsResolver());
// Tip: Find more about Java SDK at https://kontent.ai/learn/java
SimpleArticle item = client.getItem("my_article", SimpleArticle.class);
String description = item.toCompletableFuture().get().getBodyCopy();
// Tip: Find more about Java SDK at https://kontent.ai/learn/java
public class CustomContentLinkUrlResolver implements ContentLinkUrlResolver {
@Override
String resolveLinkUrl(Link link) {
// Resolves URLs to content items based on the Article content type
if ("my_article".equals(link.getCodename())) {
return String.format("/articles/%s", link.getUrlSlug());
}
}
}
public class CustomBrokenContentLinkUrlResolver implements BrokenLinkUrlResolver {
@Override
String resolveBrokenLinkUrl() {
// Resolves URLs to unavailable content items
return "/404";
}
}
// You can also register lambdas with the DeliveryClient as the resolvers are functional interfaces: https://kontent.ai/learn/java-register-resolver
// Sets the resolver as an optional dependency of the DeliveryClient
DeliveryClient client = new DeliveryClient("<YOUR_ENVIRONMENT_ID>");
client.setContentLinkUrlResolver(new CustomContentLinkUrlResolver());
client.setBrokenLinkUrlResolver(new CustomBrokenContentLinkUrlResolver());
// Tip: Find more about Java SDK at https://kontent.ai/learn/java
SimpleArticle item = client.getItem("my_article", SimpleArticle.class);
String description = item.toCompletableFuture().get().getBodyCopy();