Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita30b93b

Browse files
committed
wip
1 parent47ed550 commita30b93b

File tree

47 files changed

+186
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+186
-82
lines changed

‎build/index.js

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
constpath=require('path');
22

33
constMetalsmith=require('metalsmith');
4+
constmultimatch=require('multimatch');
45

56
// plugins
6-
constmultiLanguage=require('metalsmith-multi-language');
77
constcollections=require('metalsmith-collections');
8-
constpermalinks=require('metalsmith-permalinks');
98
constlinkcheck=require('metalsmith-linkcheck');
109
constdates=require('metalsmith-jekyll-dates');
1110
constassets=require('metalsmith-assets');
@@ -16,8 +15,9 @@ const moment = require('moment');
1615
// custom plugins
1716
constlink_index=require('./plugins/link_index');
1817
constcategories=require('./plugins/categories');
18+
constpermalinks=require('./plugins/permalinks');
1919
constchangeExt=require('./plugins/change-ext');
20-
constmarkdown=require('./plugins/markdown');
20+
constmarkdown=require('./plugins/remark');
2121
constlocales=require('./plugins/locales');
2222
constlayouts=require('./plugins/layouts');
2323
constorder=require('./plugins/order');
@@ -32,7 +32,23 @@ Metalsmith(cwd)
3232
sitename:'NativeScript-Vue',
3333
siteurl:'https://nativescript-vue.org/',
3434
description:'Build truly native apps using Vue.js',
35-
moment
35+
moment,
36+
lang(locale){
37+
constfound=this.links.find(l=>l.endsWith(`${this.slug}/index.html`)&&l.includes(locale));
38+
if(found){
39+
returnfound;
40+
}
41+
return`/${locale==='en' ?'' :locale}`;
42+
}
43+
})
44+
.use((files,metalsmith,done)=>{
45+
metalsmith.matches=(name,pattern)=>multimatch(name,pattern).length>0;
46+
metalsmith.rename=(file,to)=>{
47+
constdata=files[file];
48+
deletefiles[file];
49+
files[to]=data;
50+
};
51+
done();
3652
})
3753
// look for files in the content directory
3854
.source('./content')
@@ -42,8 +58,9 @@ Metalsmith(cwd)
4258
.clean(true)
4359
// ignore directories and files starting with an _
4460
.ignore([
45-
'_**/*',
46-
'**/_*',
61+
'_**',
62+
'.**',
63+
'**.json',
4764
])
4865
// watch the content dir when in dev mode (--dev)
4966
.use(when(isDev,watch({
@@ -52,23 +69,24 @@ Metalsmith(cwd)
5269
"layouts/**/*":'**/*.md',
5370
}
5471
})))
72+
.use(order())
5573
.use(locales({
5674
defaultLocale:'en',
57-
locales:['en','hu']
75+
locales:['en']
5876
}))
59-
.use(order())
6077
.use(categories())
6178
// group certain files into collections
6279
.use(collections({
6380
blog:{
6481
pattern:'blog/*.md',
6582
sortBy:'date',
6683
reverse:true,
84+
refer:false
6785
},
6886
docs:{
6987
pattern:'docs/**/*.md',
7088
sortBy:'order',
71-
refer:true
89+
refer:false
7290
}
7391
}))
7492
// use jekyll style dates in the file names
@@ -84,19 +102,18 @@ Metalsmith(cwd)
84102
.use(toc())
85103
// generate the final files to have pretty urls
86104
.use(permalinks({
87-
relative:false,
88-
89-
linksets:[
105+
sets:[
90106
{
91-
match:{collection:'blog'},
92-
pattern:'blog/:date/:slug',
107+
pattern:'blog/**/*',
108+
format:'blog/:slug',
93109
},
94110
{
95-
match:{collection:'docs'},
96-
pattern:':locale/docs/:title'
111+
pattern:'docs/**/*',
112+
format:':locale/docs/:slug/index.html'
97113
}
98114
]
99115
}))
116+
.use(link_index())
100117
// render all files in side a layout if specified
101118
.use(layouts({
102119
default:'post.ejs',
@@ -124,7 +141,6 @@ Metalsmith(cwd)
124141
.use(linkcheck({
125142
failMissing:false
126143
}))
127-
.use(link_index())
128144
// build the site
129145
.build((err)=>{
130146
if(err){

‎build/plugins/link_index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function plugin(opts) {
1010
}
1111
});
1212

13-
// console.log(links);
13+
metalsmith.metadata().links=links;
1414
done();
1515
}
1616
}

‎build/plugins/locales.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function plugin(opts) {
1919
if(!Array.isArray(locales)){
2020
locales=[locales]
2121
}
22-
returnnewRegExp(`.*\\/(?:${locales.join('|')})\\/(.+)(\\..+)`)
22+
returnnewRegExp(`.*\\/(${locales.join('|')})\\/(.+)(\\..+)`)
2323
};
2424

2525
// creates a list of required files based on the default locale
@@ -33,7 +33,6 @@ function plugin(opts) {
3333

3434
// builds out the file structure for all the other locales
3535
otherLocales.forEach((locale)=>{
36-
3736
requiredFiles.forEach((file)=>{
3837
constoriginal_file=file.replace('{LOCALE}',defaultLocale);
3938

@@ -49,14 +48,23 @@ function plugin(opts) {
4948
fs.writeFileSync(new_file_path,contents);
5049

5150
new_files[new_file]=Object.assign({},data,{
52-
contents:newBuffer(contents)
51+
contents:newBuffer(contents),
52+
locale:locale
5353
});
5454
}
5555
})
5656
});
5757

5858
Object.assign(files,new_files);
5959

60+
Object.keys(files).forEach(file=>{
61+
constres=file.match(pattern(locales));
62+
if(res){
63+
files[file].locale=res[1];
64+
files[file].slug=res[2];
65+
}
66+
});
67+
6068
if(!!Object.keys(new_files).length){
6169
console.log(chalk.yellow('-'.repeat(process.stdout.columns)));
6270
console.log(chalk.green('Missing locale files have been detected.'));

‎build/plugins/order.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ function plugin() {
1414
data.order=res[1];
1515

1616
// rename file to not include the order
17-
files[file.replace(res[0],'')]=data;
18-
deletefiles[file];
17+
metalsmith.rename(file,file.replace(res[0],''));
1918
}
2019
});
2120
done();

‎build/plugins/permalinks.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
constPermalinks=require('permalinks');
2+
3+
module.exports=functionpermalinks(options={}){
4+
constopts=Object.assign({},{
5+
format:':name/index.html',
6+
sets:[]
7+
},options);
8+
9+
constpl=newPermalinks();
10+
11+
return(files,metalsmith,done)=>{
12+
Object.keys(files).forEach((file)=>{
13+
constset=opts.sets.find(set=>metalsmith.matches(file,set.pattern));
14+
letformat=(set&&set.format)||opts.format;
15+
16+
try{
17+
if(file.includes('index.')){
18+
format=format.replace('/index.html','.html');
19+
}
20+
21+
constl=pl.format(format,file,files[file]);
22+
files[file].path=l;
23+
metalsmith.rename(file,l)
24+
}catch(err){
25+
done(err);
26+
}
27+
});
28+
done();
29+
}
30+
};

‎build/plugins/remark.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
constremark=require('remark');
2+
constlint=require('remark-preset-lint-recommended');
3+
consthtml=require('remark-html');
4+
constreport=require('vfile-reporter');
5+
6+
functionprocessMarkdown(contents){
7+
returnnewPromise((resolve,reject)=>{
8+
remark()
9+
.use(lint)
10+
.use(html)
11+
.process(contents,(err,file)=>{
12+
if(err)reject(err);
13+
14+
resolve(file);
15+
})
16+
})
17+
}
18+
19+
module.exports=functionpermalinks(options={}){
20+
constopts=Object.assign({},{
21+
pattern:'**/*.md',
22+
rename:true
23+
},options);
24+
25+
returnasync(files,metalsmith,done)=>{
26+
for(fileofObject.keys(files)){
27+
constdata=files[file];
28+
29+
if(!metalsmith.matches(file,opts.pattern)){
30+
continue;
31+
}
32+
33+
try{
34+
constres=awaitprocessMarkdown(data.contents);
35+
36+
if(res.messages.length>0){
37+
// console.log(`${file}:\n${report(res)}`);
38+
}
39+
data.contents=res.toString();
40+
}catch(err){
41+
console.log(`${file}:${report(err)}`);
42+
43+
done(err);
44+
}
45+
}
46+
47+
done();
48+
}
49+
};

‎content/blog/2017-12-22-we-have-a-new-site.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ console.log('????');
1616
console.log('helllooo??? why is this not working????');
1717
```
1818

19-
but in the end it turned out great.
19+
but in the end it turned out great.

‎content/blog/2017-12-24-code-sharing-coming-soon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ toc: true
66

77
One of our biggest goals is to allow developers to write
88
their web and mobile applications by sharing most of the
9-
business logic.
9+
business logic.

‎content/docs/en/1-quick-start.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,3 @@ or
7171
```sh
7272
tns run ios
7373
```
74-

‎content/docs/en/10-articles.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@ contributors: [rdlauer, naderio]
66
-[A new Vue for NativeScript](https://www.nativescript.org/blog/a-new-vue-for-nativescript)
77
-[Vue.js and NativeScript in One Minute](https://www.nativescript.org/blog/vue-and-nativescript-in-one-minute)
88
-[Building Native iOS and Android Apps With Vue and NativeScript](https://developer.telerik.com/products/nativescript/native-ios-android-vue-nativescript/)
9-
-[Native apps with Vue.js: Weex or NativeScript?
10-
](https://hackernoon.com/native-apps-with-vue-js-weex-or-nativescript-8d8f0bac041d)
11-
9+
-[Native apps with Vue.js: Weex or NativeScript?](https://hackernoon.com/native-apps-with-vue-js-weex-or-nativescript-8d8f0bac041d)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp