Skip to content

Commit e29c708

Browse files
committed
support multiple versions
1 parent 481b54d commit e29c708

File tree

12 files changed

+182
-14
lines changed

12 files changed

+182
-14
lines changed

build/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const permalinks = require('./plugins/permalinks');
2323
const changeExt = require('./plugins/change-ext');
2424
const markdown = require('./plugins/remark');
2525
const locales = require('./plugins/locales');
26+
const versions = require('./plugins/versions');
2627
const layouts = require('./plugins/layouts');
2728
const order = require('./plugins/order');
2829
const toc = require('./plugins/toc');
@@ -116,6 +117,16 @@ Metalsmith(cwd)
116117
defaultLocale: 'en',
117118
locales: ['en', 'ko', 'pt-BR', 'ru']
118119
}))
120+
.use(versions({
121+
versions: [
122+
{ name: 'latest', url: '//nativescript-vue.org' },
123+
{ name: 'v1.3.1', url: '//v1.3.1.nativescript-vue.org' },
124+
],
125+
currentVersion: {
126+
name: 'latest',
127+
branch: 'master'
128+
} // different for each branch
129+
}))
119130
.use(order())
120131
.use(categories())
121132
// group certain files into collections

build/plugins/versions.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function plugin(opts) {
2+
3+
return function (files, metalsmith, done) {
4+
const meta = metalsmith.metadata();
5+
// set global information about the available versions
6+
meta.defaultVersions = opts.defaultVersion;
7+
meta.versions = opts.versions;
8+
meta.currentVersion = opts.currentVersion;
9+
10+
done();
11+
}
12+
}
13+
14+
module.exports = plugin;

content/docs/en/elements/components/label.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ contributors: [MisterBrownRSA, rigor789, eddyverbruggen, ikoevska]
1818

1919
### Styling the label
2020

21-
If you need to style parts of the text, you can use a combination of a [`FormattedString`](https://docs.nativescript.org/cookbook/formatted-string-ng) and [`Span`](https://docs.nativescript.org/api-reference/classes/_text_span_.span) elements.
21+
If you need to style parts of the text, you can use a combination of a [`FormattedString`](https://docs.nativescript.org/angular/ui/ng-ui-widgets/formatted-string) and [`Span`](https://docs.nativescript.org/api-reference/classes/_text_span_.span) elements.
2222

2323
```html
2424
<Label textWrap="true">

content/docs/en/getting-started/5-nativescript-plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ contributors: [EddyVerbruggen, naderio, rigor789, ikoevska]
55

66
Plugins work as in [any other NativeScript app](https://docs.nativescript.org/plugins/plugins), but you may wonder how *UI* plugins work with Vue.
77

8-
UI plugins work almost identically to how you'd [use a NativeScript UI plugin in an Angular app](https://docs.nativescript.org/angular/plugins/plugins).
8+
UI plugins work almost identically to how you'd use a NativeScript UI plugin in an Angular app.
99

1010
## Sample use: nativescript-gradient
1111

content/docs/en/routing/vue-router.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ Vue Router has more tricks up its sleeve, so be sure to visit [the official docu
109109

110110
Check out the following [NativeScript-Vue samples](https://github.com/nativescript-vue/nativescript-vue/tree/master/samples):
111111

112-
* [app-with-page-routing](nativescript-vue/samples/app/app-with-page-routing.js)
113-
* [app-with-router](nativescript-vue/samples/app/app-with-router.js)
114-
* [app-with-router-pages](nativescript-vue/samples/app/app-with-router-pages.js)
112+
* [app-with-page-routing](https://github.com/nativescript-vue/nativescript-vue/tree/master/samples/app/app-with-page-routing.js)
113+
* [app-with-router](https://github.com/nativescript-vue/nativescript-vue/tree/master/samples/app/app-with-router.js)
114+
* [app-with-router-pages](https://github.com/nativescript-vue/nativescript-vue/tree/master/samples/app/app-with-router-pages.js)

content/docs/ko/getting-started/4-templates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ contributors: [qgp9]
44
outdated: true
55
---
66

7-
여러분의 `nativescript-vue` 앱을 시작하기 위해 네이티브-스크립트의 [템플릿 시스템](https://docs.nativescript.org/tooling/app-templates)을 사용할 수 있습니다. 이 템플릿들은 `nativescript-vue` 플러그인을 사용하는 네이티브-스크립트 앱을 생성합니다. 어떤 템플릿들은 Vue.js 단일 파일 컴포넌트(`.vue`) 와 라이브-리로드(livereload) 지원과 같은 추가 기능이 내장되어 있습니다.
7+
여러분의 `nativescript-vue` 앱을 시작하기 위해 네이티브-스크립트의 템플릿 시스템 을 사용할 수 있습니다. 이 템플릿들은 `nativescript-vue` 플러그인을 사용하는 네이티브-스크립트 앱을 생성합니다. 어떤 템플릿들은 Vue.js 단일 파일 컴포넌트(`.vue`) 와 라이브-리로드(livereload) 지원과 같은 추가 기능이 내장되어 있습니다.
88

99
## nativescript-vue-template
1010

content/docs/pt-BR/elements/components/label.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ contributors: [alexhiroshi]
1818

1919
### Estilizando o label
2020

21-
Se você precisa estilizar partes do texto, use a combinação de elementos [`FormattedString`](https://docs.nativescript.org/cookbook/formatted-string-ng) e [`Span`](https://docs.nativescript.org/api-reference/classes/_text_span_.span).
21+
Se você precisa estilizar partes do texto, use a combinação de elementos [`FormattedString`](https://docs.nativescript.org/angular/ui/ng-ui-widgets/formatted-string) e [`Span`](https://docs.nativescript.org/api-reference/classes/_text_span_.span).
2222

2323
```html
2424
<Label textWrap="true">

content/docs/pt-BR/getting-started/5-nativescript-plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ contributors: [alexhiroshi, WesleiRamos]
55

66
Plugins funcionam como em qualquer outro aplicativo NativeScript, mas você pode ser pergunta como plugins de *UI* funcionaria com Vue.
77

8-
Plugins de UI funcionam quase da mesma forma como você usaria um plugin de UI do NativeScript em um [aplicativo com Angular](https://docs.nativescript.org/angular/plugins/plugins).
8+
Plugins de UI funcionam quase da mesma forma como você usaria um plugin de UI do NativeScript em um aplicativo com Angular.
99

1010
## Uso de exemplo: nativescript-gradient
1111

content/docs/ru/elements/components/label.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ contributors: [sn0wil]
1818

1919
### Стилизация элемента label
2020

21-
Если вам необходимо применить стили, то вы можете использовать комбинацию элементов [`FormattedString`](https://docs.nativescript.org/cookbook/formatted-string-ng) и [`Span`](https://docs.nativescript.org/api-reference/classes/_text_span_.span).
21+
Если вам необходимо применить стили, то вы можете использовать комбинацию элементов [`FormattedString`](https://docs.nativescript.org/angular/ui/ng-ui-widgets/formatted-string) и [`Span`](https://docs.nativescript.org/api-reference/classes/_text_span_.span).
2222

2323
```html
2424
<Label textWrap="true">

layouts/_partials/header.ejs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
class="block bg-blue-light md:bg-green md:border-t-8 border-green p-4 md:p-0 text-center no-underline text-white">
55
Jun 12: Building Better Apps with NativeScript 4.0
66
</a>-->
7-
<a href="/blog/nativescript-vue-1.0-and-a-new-site/"
7+
<!--<a href="/blog/nativescript-vue-1.0-and-a-new-site/"
88
class="block md:hidden bg-green p-2 text-center no-underline text-white">
99
Announcing 1.0
10-
</a>
10+
</a>-->
1111
<div id="app" class="bg-blue-dark md:border-t-8 border-green">
1212
<div class="container flex items-center flex-wrap px-4 md:px-0 mx-auto">
1313
<div class="flex-1 flex items-center">
@@ -22,7 +22,7 @@
2222
</div>
2323
</a>
2424

25-
<div class="flex items-center">
25+
<!--<div class="flex items-center">
2626
<span role="presentation" aria-hidden="true"
2727
class="hidden lg:block w-1 h-1 bg-blue-light rounded-full ml-2"></span>
2828
<span role="presentation" aria-hidden="true"
@@ -35,7 +35,7 @@
3535
Announcing 1.0
3636
</a>
3737
</div>
38-
</div>
38+
</div>-->
3939
</div>
4040
<div class="w-auto text-center relative">
4141
<input class="docSearch-input w-full md:w-48 px-4 py-2 text-blue-lightest bg-blue-light rounded-full"
@@ -100,6 +100,22 @@
100100
</div>
101101
</div>
102102
<% } %>
103+
<% if(meta.versions.length > 1) { %>
104+
<div class="inline text-blue-lightest py-4 relative group ml-4">
105+
<span class="-md:hidden bg-blue-light rounded-sm px-2 py-1"><%= meta.currentVersion.name %></span>
106+
107+
<div class="pl-4 mt-3 md:pl-0 md:hidden group-hover:block hover:block md:absolute md:bg-white md:shadow md:rounded md:pin-r overflow-hidden z-50">
108+
<div class="flex flex-col">
109+
<% meta.versions.forEach(v => { %>
110+
<a href="<%= v.url %>"
111+
class="no-underline text-blue-lightest md:text-blue-dark hover:bg-green hover:text-white px-4 py-2">
112+
<%= v.name %>
113+
</a>
114+
<% }) %>
115+
</div>
116+
</div>
117+
</div>
118+
<% } %>
103119
</div>
104120
</div>
105121
</div>

layouts/docs.ejs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
</div>
1818
</div>
1919

20+
<% if(meta.currentVersion.branch !== 'master') { %>
21+
<a href="//nativescript-vue.org/"
22+
class="block bg-orange-dark p-2 text-center no-underline text-white">
23+
You are reading docs for <span class="bg-orange-lightest text-orange-dark rounded-sm px-2 py-1"><%= meta.currentVersion.name %></span>, click here for the latest version.
24+
</a>
25+
<% } %>
26+
2027
<div class="md:bg-docs-gradient min-h-screen">
2128
<div class="container mx-auto flex">
2229
<div class="hidden md:w-1/4 md:block border-r-4 min-h-full">
@@ -81,7 +88,7 @@
8188
<% } %>
8289

8390
<div class="flex justify-center">
84-
<a href="https://github.com/nativescript-vue/nativescript-vue.org/tree/master/content/<%= current.filePath %>"
91+
<a href="https://github.com/nativescript-vue/nativescript-vue.org/tree/<%= meta.currentVersion.branch %>/content/<%= current.filePath %>"
8592
target="_blank"
8693
rel="noopener"
8794
class="border border-green px-4 py-2 no-underline text-green hover:border-blue-dark hover:text-blue-dark my-8">

0 commit comments

Comments
 (0)