Skip to content

Commit

Permalink
Update buildSearch() to remove "component" search result type
Browse files Browse the repository at this point in the history
  • Loading branch information
gakimball committed Dec 31, 2016
1 parent 54ac48b commit d683c34
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
7 changes: 0 additions & 7 deletions packages/spacedoc/lib/buildSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const writeFile = pify(require('fs').writeFile);
* @returns {Promise} Promise which resolves when the search file has been written to disk.
* @todo Add hashes for doclet results
* @todo Make hashes for search result types configurable
* @todo Remove the page/component distinction, which is too specific
* @todo Fix search result page paths being relative
*/
module.exports = function buildSearch(outFile = this.options.search.output) {
Expand All @@ -35,12 +34,6 @@ module.exports = function buildSearch(outFile = this.options.search.output) {
const item = tree[i];
const link = path.relative(this.options.pageRoot, item.fileName).replace('md', this.options.extension);
const type = (() => {
// By default pages are classified as a "page"
// If it has code associated with it, then it's a "component" instead.
if (keysInObject(item.docs, Object.keys(this.adapters))) {
return 'component';
}

// Check for special page types
for (let t in this.options.search.pageTypes) {
const func = this.options.search.pageTypes[t];
Expand Down
21 changes: 1 addition & 20 deletions packages/spacedoc/test/buildSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Spacedoc.buildSearch()', () => {
return s.init().then(() => s.buildSearch('test/fixtures/_build/search.json'));
});

it('flags generic pages as "page"', () => {
it('flags pages as "page"', () => {
const s = new Spacedoc().config({
input: 'test/fixtures/example.md',
template: 'test/fixtures/template.pug',
Expand All @@ -35,25 +35,6 @@ describe('Spacedoc.buildSearch()', () => {
});
});

it('flags pages with code hooks as "component"', () => {
const s = new Spacedoc().config({
adapters: Adapters,
input: 'test/fixtures/example.md',
template: 'test/fixtures/template.pug',
silent: true
});

return s.init().then(() => s.buildSearch('test/fixtures/_build/search.json')).then(() => {
var data = fs.readFileSync('./test/fixtures/_build/search.json').toString();
data = JSON.parse(data);

for (var i in data) {
if (data[i].name === 'Button')
expect(data[i].type).to.equal('component')
}
});
});

it('allows for custom page types', () => {
const s = new Spacedoc().config({
input: 'test/fixtures/example.md',
Expand Down

0 comments on commit d683c34

Please sign in to comment.