Merge pull request #857 from QingWei-Li/feat/changelog

Changelog(doc): auto generate links
This commit is contained in:
baiyaaaaa 2016-11-06 19:29:45 +08:00 committed by GitHub
commit 0391488b48
4 changed files with 32 additions and 15 deletions

View File

@ -118,6 +118,7 @@
name: 'app',
methods: {
renderAnchorHref() {
if (/changelog/g.test(location.href)) return;
const anchors = document.querySelectorAll('h2 a,h3 a');
const basePath = location.href.split('#').splice(0, 2).join('#');

View File

@ -7,8 +7,8 @@
</head>
<body>
<div id="app"></div><% if (process.env.NODE_ENV === 'production') { %>
<script src="//cdn.jsdelivr.net/vue/2.0.3/vue.min.js"></script>
<script src="//cdn.jsdelivr.net/vue.router/2.0.1/vue-router.min.js"></script><% } %>
<script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.0.5/vue.runtime.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/vue-router/2.0.1/vue-router.min.js"></script><% } %>
</body>
<% if (process.env.NODE_ENV === 'production') { %><script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

View File

@ -14,7 +14,7 @@
color: #20a0ff;
}
}
h2 {
.heading {
margin-bottom: 40px;
}
.timeline {
@ -52,7 +52,7 @@
height: @width;
background-color: #20a0ff;
border: 0;
}
}
}
}
@ -88,6 +88,13 @@
box-sizing: border-box;
background-color: #fff;
}
a {
opacity: 1;
float: none;
margin-left: 0;
color: inherit;
}
}
h4 {
margin: 50px 0 10px;
@ -109,12 +116,12 @@
</style>
<template>
<div class="page-changelog">
<h2>
<div class="heading">
<el-button class="fr">
<a href="https://github.com/ElemeFE/element/releases" target="_blank">Github Releases</a>
</el-button>
更新日志
</h2>
</div>
<ul class="timeline" ref="timeline">
</ul>
<change-log ref="changeLog"></change-log>
@ -132,16 +139,25 @@
};
},
mounted() {
var changeLog = this.$refs.changeLog;
var changeLogNodes = changeLog.$el.children;
var fragments = '<li>' + changeLogNodes[1].outerHTML;
const changeLog = this.$refs.changeLog;
const changeLogNodes = changeLog.$el.children;
let a = changeLogNodes[1].querySelector('a');
a && a.remove();
let release = changeLogNodes[1].textContent.trim();
let fragments = `<li><h3><a href="https://github.com/ElemeFE/element/releases/tag/v${release}" target="_blank">${release}</a></h3>`;
for (let len = changeLogNodes.length, i = 2; i < len; i++) {
let node = changeLogNodes[i];
fragments += node.tagName !== 'H3'
? changeLogNodes[i].outerHTML
: `</li><li>${changeLogNodes[i].outerHTML}`;
a = changeLogNodes[i].querySelector('a');
a && a.remove();
if (node.tagName !== 'H3') {
fragments += changeLogNodes[i].outerHTML;
} else {
release = changeLogNodes[i].textContent.trim();
fragments += `</li><li><h3><a href="https://github.com/ElemeFE/element/releases/tag/v${release}" target="_blank">${release}</a></h3>`;
}
}
fragments = fragments.replace(/#(\d+)/g, '<a href="https://github.com/ElemeFE/element/issues/$1" target="_blank">#$1</a>');
this.$refs.timeline.innerHTML = `${fragments}</li>`;
changeLog.$el.remove();

View File

@ -45,7 +45,7 @@
"wind-dom": "0.0.3"
},
"peerDependencies": {
"vue": "^2.0.3"
"vue": "^2.0.0"
},
"devDependencies": {
"babel-cli": "^6.14.0",
@ -106,8 +106,8 @@
"transliteration": "^1.1.11",
"uppercamelcase": "^1.1.0",
"url-loader": "^0.5.7",
"vue": "^2.0.3",
"vue-loader": "^9.7.0",
"vue": "^2.0.5",
"vue-loader": "^9.8.0",
"vue-markdown-loader": "^0.5.1",
"vue-router": "^2.0.0",
"webpack": "^1.13.2",