Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #96 from nodejitsu/nicedesc

Nice description for search page
  • Loading branch information...
commit 2b60238097e145b0399684338a57c0ce9dd91e2b 2 parents 981176f + a2f7112
@3rd-Eden 3rd-Eden authored
Showing with 14 additions and 27 deletions.
  1. +10 −22 README.md
  2. +3 −4 index.js
  3. +1 −1  package.json
View
32 README.md
@@ -76,41 +76,28 @@ details about data for all keys, see [Description, title and tags][description].
[description]: #description-title-and-tags
### Get the catalog
-Call `handbook.catalogSync()` to aquire a complete catalog from content
-(sychronously), which should return an object with paths, href's and titles.
+Call `handbook.catalog()` to aquire a complete catalog from content
+(sychronously), which should return an object with paths, href's, titles and
+descriptions. If you want to generate the catalog asynchronously then supply a
+callback to the function.
``` javascript
{
- content: {
+ index: {
index: {
href: '',
title: 'Handbook',
+ description: '# Introduction\n\nWelcome to the Nodejitsu handbook. This document will help familiarize you with\ndeploying your Node.js applications to the cloud while also providing detailed\ninformation about Nodejitsu\'s platform-specific features and about\nwhere to get help when you need it.',
path: '/var/www/nodejitsu/handbook/content'
}
},
- 'content/support': {
+ support: {
index: {
href: '/support',
title: 'Need Support?',
+ description: '# Need Support?\n\nNodejitsu has a team of developers standing by to assist users with any issues\nthey may come across while deploying and administrating their web applications\non the Nodejitsu platform. Nodejitsu strives to have a lightning-fast turnaround\non all issues you may have!',
path: '/var/www/nodejitsu/handbook/content/support'
}
- },
- 'content/a-quickstart': {
- index: {
- href: '/a-quickstart',
- title: 'Quickstart',
- path: '/var/www/nodejitsu/handbook/content/a-quickstart'
- },
- faq: {
- href: '/a-quickstart/faq',
- title: 'FAQ',
- path: '/var/www/nodejitsu/handbook/content/a-quickstart'
- },
- 'hello-world': {
- href: '/a-quickstart/hello-world',
- title: 'Hello World: A Tutorial',
- path: '/var/www/nodejitsu/handbook/content/a-quickstart'
- }
}
}
```
@@ -118,7 +105,8 @@ Call `handbook.catalogSync()` to aquire a complete catalog from content
### Description, title and tags
Adding a description and title to the article is as easy as providing it at the
bottom of the content as per example. Omitting title and/or description is
-possible as an empty string will be returned.
+possible. The description will be parsed from the first lines of the content.
+The title will be returned with an empty string.
``` markdown
[meta:title]: <> (Using the jitsu CLI)
View
7 index.js
@@ -6,11 +6,10 @@ var path = require('path'),
lunr = require('lunr'),
tokenizer = new natural.WordTokenizer(),
loc = path.resolve(__dirname, 'content'),
- html = /(<[^>]*>)|(&[^;]+;)/g,
scraper = {
title: /\[meta:title\]:\s<>\s\((.+?)\)(?!\))/,
description: /\[meta:description\]:\s<>\s\((.+?)\)(?!\))/,
- firstline: /([\-a-zA-Z0-9&;,]*\s+){5,}\w*/
+ firstlines: /^((.*\n){2}){1,3}/
};
//
@@ -23,7 +22,7 @@ var path = require('path'),
function scrape(content, key, n) {
if (!content) return '';
- var match = content.replace(/\n/g, ' ').match(scraper[key]);
+ var match = content.match(scraper[key]);
// Only return scraped content if there is a meta:[key].
return match && match[n] ? match[n].trim() : '';
@@ -48,7 +47,7 @@ function normalize(file) {
function fileContent(content) {
return {
content: content || '',
- description: scrape(content, 'description', 1) || scrape(content, 'firstline', 0),
+ description: scrape(content, 'description', 1) || scrape(content, 'firstlines', 0),
title: scrape(content, 'title', 1),
tags: tags(content, 10)
};
View
2  package.json
@@ -2,7 +2,7 @@
"author": "Nodejitsu <support@nodejitsu.com> (http://nodejitsu.com)",
"name": "handbook",
"description": "A gentle introduction to the art of nodejitsu",
- "version": "0.4.0",
+ "version": "0.4.1",
"subdomain": "handbook",
"homepage": "http://www.nodejitsu.com/docs",
"repository": {
Please sign in to comment.
Something went wrong with that request. Please try again.