Browse Source

Create shouldSSR()

Shun Miyazawa 2 năm trước cách đây
mục cha
commit
95dc919872
1 tập tin đã thay đổi với 13 bổ sung0 xóa
  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');
   };
 
+  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) {
     // Reset
     this.grantedUsers = [];