Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add raw max len #39

Open
wants to merge 2 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -121,6 +121,7 @@ Options:
--indexing-key An algolia API key with add/delete records permissions.
It should be different than the search-only API key configured in _config.yml.
--layouts A comma-separated list of page layouts to index (default: "page").
--max-raw-size raw length(k), default is 8k.
```

### Security Concerns
@@ -10,7 +10,8 @@ var CONSOLE_DEFAULTS = {
dryRun: false,
flush: false,
chunkSize: 50,
layouts: INDEXED_LAYOUTS
layouts: INDEXED_LAYOUTS,
maxRawSize: 8
};

var INDEXED_PROPERTIES = [
@@ -21,7 +22,8 @@ var INDEXED_PROPERTIES = [
'excerpt',
'permalink',
'layout',
'image'
'image',
'raw'
];

function computeSha1(text) {
@@ -102,7 +104,12 @@ module.exports = function(args, callback) {
.then(function(publishedPagesAndPosts) {
return publishedPagesAndPosts.map(function(data) {
var storedPost = pick(data, INDEXED_PROPERTIES);

var rawBuf = new Buffer(data.raw)
var rowSize = options.maxRawSize * 1024
if (rawBuf.length > rowSize) {
storedPost.raw = rawBuf.toString("utf8", 0, rowSize)
storedPost.raw = storedPost.raw.substring(0, storedPost.raw.length - 1)
}
storedPost.objectID = computeSha1(data.path);
storedPost.date_as_int = Date.parse(data.date) / 1000;
storedPost.updated_as_int = Date.parse(data.updated) / 1000;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.