Skip to content

Commit

Permalink
feat(headline): add ability to use custom headline
Browse files Browse the repository at this point in the history
update dependencies

#14
  • Loading branch information
ph1p committed Apr 2, 2019
1 parent a9773b9 commit 8aa34d1
Show file tree
Hide file tree
Showing 15 changed files with 1,309 additions and 611 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ You can add custom meta data your pages by using the `@vuepress` block:
* @vuepress
* ---
* title: Your custom title
* headline: You custom headline
* ---
*/
```

Use `headline` to add a custom `h1` title.

[More information](https://vuepress.vuejs.org/guide/markdown.html#front-matter)

## Example
Expand Down
12 changes: 10 additions & 2 deletions cmds/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async function generate(argv) {
]
});
} catch (e) {
console.log(chalk.black.bgBlue('exlude by config'), `${folderPath}/${fileName}.md`);
console.log(chalk.black.bgBlue('exclude by config'), `${folderPath}/${fileName}.md`);
}
}

Expand All @@ -138,7 +138,15 @@ async function generate(argv) {

fileContent += '\n---\n';
if ((attributes && attributes.title) || !/\.vue$/.test(file)) {
fileContent += `\n# ${attributes && attributes.title ? attributes.title : fileName}\n\n`;
let headline = fileName;

if (attributes && attributes.headline) {
headline = attributes.headline;
} else if (attributes && attributes.title) {
headline = attributes.title;
}

fileContent += `\n# ${headline}\n\n`;
}
fileContent += mdFileData;

Expand Down
4 changes: 2 additions & 2 deletions example/documentation/code/class.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: class.js
title: class
test: test class
---

# class.js
# class

<a name="Test"></a>

Expand Down
5 changes: 2 additions & 3 deletions example/documentation/code/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ exports.fileTree = [
]
},
{ name: 'test', path: '/test', fullPath: './documentation/code/test' },
{ name: 'tests', children: [{ name: 'first.test', path: '/first.test', fullPath: 'tests/first.test' }] }
{ name: 'tests', children: [] }
];
exports.sidebarTree = (title = 'Mainpage') => ({
'/code/': [
{ title: 'API', collapsable: false, children: [['', '' + title + ''], 'class', 'methods', 'objects', 'test'] },
{ title: 'lib', collapsable: false, children: ['lib/dmd-options', 'lib/jsdoc-to-markdown'] },
{ title: 'subfolder', collapsable: false, children: ['subfolder/subfolder.1/variables', 'subfolder/variables'] },
{ title: 'tests', collapsable: false, children: ['tests/first.test'] }
{ title: 'subfolder', collapsable: false, children: ['subfolder/subfolder.1/variables', 'subfolder/variables'] }
]
});
4 changes: 2 additions & 2 deletions example/documentation/code/lib/dmd-options.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: dmd-options.js
title: dmd-options
---

# dmd-options.js
# dmd-options

<a name="DmdOptions"></a>

Expand Down
4 changes: 2 additions & 2 deletions example/documentation/code/lib/jsdoc-to-markdown.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: jsdoc-to-markdown.js
title: jsdoc-to-markdown
---

# jsdoc-to-markdown.js
# jsdoc-to-markdown

<a name="module_jsdoc-to-markdown"></a>

Expand Down
3 changes: 2 additions & 1 deletion example/documentation/code/methods.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
title: A normal ES6 Method
headline: Custom Title!
---

# A normal ES6 Method
# Custom Title!

## Functions

Expand Down
4 changes: 2 additions & 2 deletions example/documentation/code/objects.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: objects.js
title: objects
---

# objects.js
# objects

<a name="obj"></a>

Expand Down
4 changes: 2 additions & 2 deletions example/documentation/code/subfolder/subfolder.1/variables.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: variables.js
title: variables
---

# variables.js
# variables

## Members

Expand Down
4 changes: 2 additions & 2 deletions example/documentation/code/subfolder/variables.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: variables.js
title: variables
---

# variables.js
# variables

## Members

Expand Down
5 changes: 1 addition & 4 deletions example/documentation/code/test.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
title: test.vue
title: test
---

# test.vue

# test

- **vue**
Expand Down
15 changes: 0 additions & 15 deletions example/documentation/code/tests/first.test.md

This file was deleted.

1 change: 1 addition & 0 deletions example/src/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @vuepress
* ---
* title: A normal ES6 Method
* headline: Custom Title!
* ---
*/
/**
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@
"bluebird": "^3.5.3",
"chalk": "^2.4.2",
"cross-env": "^5.2.0",
"del": "^3.0.0",
"del": "^4.1.0",
"front-matter": "^3.0.1",
"fs.promised": "^3.0.0",
"jsdoc-to-markdown": "^4.0.1",
"micromatch": "^3.1.10",
"mkdirp": "^0.5.1",
"rimraf": "^2.6.3",
"yargs": "^13.2.1"
"yargs": "^13.2.2"
},
"devDependencies": {
"conventional-changelog-cli": "^2.0.12",
"eslint": "^5.14.1",
"husky": "^1.3.1",
"jest": "^24.1.0",
"jest": "^24.6.0",
"lint-staged": "^8.1.4"
},
"lint-staged": {
Expand Down
Loading

0 comments on commit 8aa34d1

Please sign in to comment.