generateContentRoute method

String generateContentRoute({
  1. required Datum content,
  2. required String pageKey,
})

Implementation

String generateContentRoute(
    {required Datum content, required String pageKey}) {
  late String base;
  String objectType = content.objecttype!;
  String category = content.category!;
  if (objectType == ContentModel.series) {
    if (category == ContentModel.course) {
      base = "course";
    } else {
      base = "series";
    }
  } else {
    base = "video";
  }
  String name =
      (content.title!.replaceAll("?", "")).toLowerCase().replaceAll(" ", "-");
  String tag = "content";
  try {
    tag = content.genre!.toLowerCase();
  } catch (error) {
    //do nothing here
  }
  tag = tag.replaceAll(" ", "-");
  return "/$pageKey/$base/$tag/$name/media/${content.objectid}";
}