Przeglądaj źródła

Create shouldSSR()

Shun Miyazawa 2 lat temu
rodzic
commit
95dc919872
1 zmienionych plików z 13 dodań i 0 usunięć
  1. 13 0
      apps/app/src/server/models/obsolete-page.js

+ 13 - 0
apps/app/src/server/models/obsolete-page.js

@@ -248,6 +248,19 @@ export const getPageSchema = (crowi) => {
     return this.populate('revision');
     return this.populate('revision');
   };
   };
 
 
+  pageSchema.methods.shouldSSR = async function() {
+    if (!this.isLatestRevision()) {
+      return false;
+    }
+
+    if (this.latestRevisionBodyLength == null) {
+      return true;
+    }
+
+    const ssrMaxRevisionBodyLength = crowi.configManager.getConfig('crowi', 'app:ssrMaxRevisionBodyLength');
+    return ssrMaxRevisionBodyLength >= this.latestRevisionBodyLength;
+  };
+
   pageSchema.methods.applyScope = function(user, grant, grantUserGroupId) {
   pageSchema.methods.applyScope = function(user, grant, grantUserGroupId) {
     // Reset
     // Reset
     this.grantedUsers = [];
     this.grantedUsers = [];