Constructor
new FileCollection(type, layout, config)
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type |
string | The type of file collection (i.e. posts, pages). |
|||||||||||||||
layout |
Object | The layouts of the file collection type. Properties
|
|||||||||||||||
config |
Config | Configuration from the CMS |
- Source:
Members
page :null|number
Type:
- null | number
- Source:
resultsPerPage :null|number
Type:
- null | number
- Source:
totalPages :null|number
Type:
- null | number
- Source:
totalResults :null|number
Type:
- null | number
- Source:
Methods
filterAttributeSearch(search, modeopt) → {Array.<File>}
Search file collection by arbitrary attributes
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
search |
Object | Dictionary containing key/values to search |
||
mode |
string |
<optional> |
AND | "OR" or "AND" if we should check all keys or any of them |
- Source:
- See:
-
- module:CMS~File#matchesAttributeSearch for full documentation of usage
Returns:
Set of filtered files
- Type
- Array.<File>
filterPermalink(url) → {Array.<File>}
Filter results by a URL regex (Convenience method)
Parameters:
Name | Type | Description |
---|---|---|
url |
string | URL fragment/regex to filter against |
- Source:
- See:
-
- filterAttributeSearch
Returns:
Set of filtered files
- Type
- Array.<File>
filterSearch(search) → {Array.<File>}
Search file collection by attribute.
Parameters:
Name | Type | Description |
---|---|---|
search |
string | Search query. |
- Source:
Returns:
Set of filtered files
- Type
- Array.<File>
filterSort(paramopt)
Sort results by a given parameter
If a function is requested, that is used to sort the results. If a string is requested, only specific keywords are supported. Use -r to inverse results. If NULL is requested, the default sort for this collection type is used.
Common sort parameters:
- title - Sort by page title
- random - Sort randomly
- recent - Sort by most recent
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
param |
function | string | null |
<optional> |
null | A function, string, or empty value to sort by |
- Source:
filterTag(query) → {Array.<File>}
Filter content to display by a tag (Convenience method)
Parameters:
Name | Type | Description |
---|---|---|
query |
string | Search query. |
- Source:
- See:
-
- filterAttributeSearch
Returns:
Set of filtered files
- Type
- Array.<File>
getFileByPermalink(permalink) → {File}
Get file by permalink.
Parameters:
Name | Type | Description |
---|---|---|
permalink |
string | Permalink to search. |
- Source:
Throws:
Returns:
File object.
- Type
- File
getFileElements(data) → {Array.<string>}
Get list of file elements from either the returned listing page scan (or JSON data for GITHUB)
Parameters:
Name | Type | Description |
---|---|---|
data |
string | HTML code from directory listing |
- Source:
Returns:
URLs of files and directories located
- Type
- Array.<string>
getFileListUrl() → {string}
Get file list URL
- Source:
Returns:
URL of file list
- Type
- string
(async) getFiles() → {Promise}
Get files from file listing and set to file collection.
- Source:
Returns:
- Type
- Promise
(async) getFilesByServer() → {Promise}
Get files from file listing and set to file collection.
- Source:
Returns:
- Type
- Promise
getNextPageUrl() → {string}
Get the URL for the next page (when pagination is enabled)
- Source:
Returns:
- Type
- string
getPageUrl(page) → {string}
Get the URL for the requested page (when pagination is enabled)
Parameters:
Name | Type | Description |
---|---|---|
page |
number |
- Source:
Returns:
- Type
- string
getPreviousPageUrl() → {string}
Get the URL for the previous page (when pagination is enabled)
- Source:
Returns:
- Type
- string
getTags(sortopt, weightMaxopt) → {Object}
Get all tags located from this collection
Each set will contain the properties name
, count
, url
, and weight
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
sort |
string | null |
<optional> |
null | Key ['name', 'count', 'url'] to sort results |
weightMax |
number |
<optional> |
10 | Max weight |
- Source:
Returns:
{{name: string, count: number, url: string, weight: int}[]}
- Type
- Object
(async) init() → {Promise}
Initialize file collection
- Source:
Returns:
- Type
- Promise
(async) loadFiles() → {Promise}
Load files and get file content.
- Source:
Returns:
- Type
- Promise
paginate(results)
Set pagination (total number of results) for this collection
Parameters:
Name | Type | Description |
---|---|---|
results |
number |
- Source:
(async) render() → {Promise}
Renders file collection.
- Source:
Throws:
Returns:
- Type
- Promise
resetFilters()
Reset filters and sorting
- Source:
(async) scanDirectory(directory) → {Promise.<Array.<string>>}
Perform the underlying directory lookup
Parameters:
Name | Type | Description |
---|---|---|
directory |
string | Directory URL to scan |
- Source:
Returns:
Array of subdirectories found
- Type
- Promise.<Array.<string>>