types.js 658 B

1234567891011121314151617181920212223242526
  1. app.collections.Types = class Types extends app.Collection {
  2. static model = "Type";
  3. static GUIDES_RGX =
  4. /(^|\()(guides?|tutorials?|reference|book|getting\ started|manual|examples)($|[\):])/i;
  5. static APPENDIX_RGX = /appendix/i;
  6. groups() {
  7. const result = [];
  8. for (var type of this.models) {
  9. const name = this._groupFor(type);
  10. result[name] ||= [];
  11. result[name].push(type);
  12. }
  13. return result.filter((e) => e.length > 0);
  14. }
  15. _groupFor(type) {
  16. if (Types.GUIDES_RGX.test(type.name)) {
  17. return 0;
  18. } else if (Types.APPENDIX_RGX.test(type.name)) {
  19. return 2;
  20. } else {
  21. return 1;
  22. }
  23. }
  24. };