Custom Homepage for Groups

I’m still not sure why I deleted support for the default and anon homepages before. I put those back.

Now if there is a custom_default_homepage it uses that unless there is a matching group match. If there’s an anon_page and the user is anonymous, it uses that.

I couldn’t figure out how or when the mobile page should be set (is it for anon users? all users? does it override the default page? the group map?), so I deleted it. If you’re using that mobile page, tell me what you think it should override (I think maybe set it as the default page if they are on mobile, but if there is a group page, then use that? Still not clear what to do for anon vs logged in–I guess there maybe needs to be mobile versions for all of them?).

Here’s the code:

      let url = null;

      if (settings.custom_default_homepage) {
        url = settings.custom_default_homepage.replace(/^\/+/g, "");
      }

      if (user) {
        if (user.primary_group_name && settings.group_page_map) {
          let groupMap = settings.group_page_map.replace(",", ":").split("|");
          const mapEntry = groupMap.find((value) =>
            RegExp(user.primary_group_name).test(value)
          );
          if (mapEntry) {
            url = mapEntry.split(":")[1].replace(/^\/+/g, "");
          }
        }
      } else if (settings.anon_page) {
        url = settings.anon_page.replace(/^\/+/g, "");
      }

And then it changes the homepage only if url has a value.

5 Likes