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

Commit6d7a34d

Browse files
committed
Initial commit
0 parents  commit6d7a34d

16 files changed

+346
-0
lines changed

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist
2+
node_modules
3+
content/.links_checked.json
4+
content/links_failed.json

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#NativeScript-Vue website
2+
3+
This is a WIP statically generated website

‎build/index.js‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
constpath=require('path');
2+
3+
constMetalsmith=require('metalsmith');
4+
5+
// plugins
6+
constmultiLanguage=require('metalsmith-multi-language');
7+
constcollections=require('metalsmith-collections');
8+
constpermalinks=require('metalsmith-permalinks');
9+
constlinkcheck=require('metalsmith-linkcheck');
10+
constdates=require('metalsmith-jekyll-dates');
11+
constinPlace=require('metalsmith-in-place');
12+
constlayouts=require('metalsmith-layouts');
13+
constwatch=require('metalsmith-watch');
14+
constwhen=require('metalsmith-if');
15+
16+
// custom plugins
17+
constchangeExt=require('./plugins/change-ext');
18+
constmarkdown=require('./plugins/markdown');
19+
consttoc=require('./plugins/toc');
20+
21+
constisDev=process.argv[2]==='--dev';
22+
constcwd=path.resolve(__dirname,'..');
23+
24+
Metalsmith(cwd)
25+
// set globally available metadata
26+
.metadata({
27+
sitename:'NativeScript-Vue',
28+
siteurl:'https://nativescript-vue.org/',
29+
description:'Build truly native apps using Vue.js'
30+
})
31+
// look for files in the content directory
32+
.source('./content')
33+
// output files to the dist directory
34+
.destination('./dist')
35+
// clean the dist directory before building
36+
.clean(true)
37+
// ignore directories and files starting with an _
38+
.ignore([
39+
'_**/*',
40+
'**/_*',
41+
])
42+
// watch the content dir when in dev mode (--dev)
43+
.use(when(isDev,watch({
44+
paths:{
45+
"${source}/**/*.{md, ejs}":true,
46+
"layouts/**/*":'**/*.md',
47+
}
48+
})))
49+
// group certain files into collections
50+
.use(collections({
51+
blog:'blog/*.md',
52+
docs:{
53+
pattern:'docs/**/*.md',
54+
refer:false
55+
}
56+
}))
57+
// use jekyll style dates in the file names
58+
.use(dates())
59+
// use multiple languages
60+
.use(multiLanguage({
61+
default:'en',
62+
locales:['en','hu']
63+
}))
64+
// render markdown using our own plugin around marked
65+
.use(markdown())
66+
// add table of contents using our own plugin
67+
.use(toc())
68+
// generate the final files to have pretty urls
69+
.use(permalinks({
70+
relative:false,
71+
72+
linksets:[
73+
{
74+
match:{collection:'blog'},
75+
pattern:'blog/:date/:slug',
76+
},
77+
{
78+
match:{collection:'docs'},
79+
pattern:':locale/docs/:title'
80+
}
81+
]
82+
}))
83+
// allow inPlace to process files
84+
.use(changeExt({
85+
pattern:`*.html`,
86+
ext:'.ejs'
87+
}))
88+
// wrap content in handlebars layouts
89+
.use(layouts({
90+
engine:'ejs',
91+
default:'default.ejs',
92+
partials:'layouts/_partials',
93+
partialExtension:'.ejs',
94+
rename:false
95+
}))
96+
// allow using template features inside the content directory
97+
.use(inPlace({
98+
engineOptions:{
99+
partials:'layouts/_partials',
100+
}
101+
}))
102+
// finally check if we have broken links
103+
.use(linkcheck({
104+
failMissing:false
105+
}))
106+
// build the site
107+
.build((err)=>{
108+
if(err){
109+
console.log(err.toString())
110+
}
111+
});

‎build/plugins/change-ext.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
constmultimatch=require('multimatch');
2+
constpath=require('path');
3+
4+
functionplugin(opts){
5+
6+
returnfunction(files,metalsmith,done){
7+
Object.keys(files).forEach((file)=>{
8+
if(multimatch(file,opts.pattern).length){
9+
constdata=files[file];
10+
constnew_name=path.extname(file)+opts.ext;
11+
deletefiles[file];
12+
files[new_name]=data;
13+
}
14+
});
15+
16+
done();
17+
}
18+
}
19+
20+
module.exports=plugin;

‎build/plugins/markdown.js‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
constmarked=require('marked');
2+
3+
// allow injecting partials
4+
// from: > partial:partialname
5+
// to: {{> partialname }}
6+
functionhandlebarPartials(renderer){
7+
((b)=>{
8+
renderer.blockquote=(quote)=>{
9+
constmatch=quote.match(/<p>partial:(.+)<\/p>/);
10+
if(match){
11+
return`{{>${match[1]} }}`
12+
}else{
13+
returnb(quote)
14+
}
15+
}
16+
})(renderer.blockquote);
17+
}
18+
19+
functionplugin(opts){
20+
constrenderer=newmarked.Renderer();
21+
22+
renderer.heading=function(text,level,raw){
23+
letparsed=parseAnchor(raw);
24+
letid=parsed.id;
25+
26+
return(
27+
`<h${level} class="header">`+
28+
`<a class="anchor" href="#${id}" id="${id}"></a>`+
29+
`<a class="icon-link" href="#${id}">${text}</a>`+
30+
`</h${level}>\n`
31+
);
32+
};
33+
34+
handlebarPartials(renderer);
35+
36+
marked.setOptions(Object.assign({renderer},opts));
37+
38+
returnfunction(files,metalsmith,done){
39+
40+
Object.keys(files).forEach((file)=>{
41+
if(!file.endsWith('.md')){
42+
return
43+
}
44+
45+
constdata=files[file];
46+
constnew_name=file.replace('.md','.html');
47+
48+
if(data.extends){
49+
// console.log('should extend though...')
50+
}
51+
52+
data.contents=newBuffer(marked(data.contents.toString()));
53+
deletefiles[file];
54+
files[new_name]=data;
55+
});
56+
57+
done();
58+
}
59+
}
60+
61+
functionparseAnchor(string){
62+
varstripped=string.replace(/\[(.+)\]\(.+\)/gi,'$1').replace(/(<([^>]+)>)/ig,'');
63+
varclean=stripped.replace(/`/g,'');
64+
65+
return{
66+
title:clean,
67+
id:clean.replace(/[^\w]+/g,'-').toLowerCase()
68+
};
69+
}
70+
71+
module.exports=plugin;

‎build/plugins/toc.js‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
constpath=require('path');
2+
constfs=require('fs');
3+
consttocJSON=require('table-of-contents-json');
4+
5+
6+
functionplugin(opts){
7+
8+
9+
returnfunction(files,metalsmith,done){
10+
Object.keys(files).forEach((file)=>{
11+
constdata=files[file];
12+
13+
if(data.toc===true){
14+
try{
15+
data.toc=newtocJSON().generateJSON(data.contents.toString());
16+
}catch(err){
17+
returndone(err);
18+
}
19+
}elseif(!!data.toc){
20+
consttocPath=path.resolve(metalsmith._source,data.paths.dir,data.toc);
21+
try{
22+
consttoc=fs.readFileSync(tocPath);
23+
data.toc=JSON.parse(toc);
24+
}catch(err){
25+
done(err);
26+
}
27+
}else{
28+
data.toc=false;
29+
}
30+
});
31+
done();
32+
}
33+
}
34+
35+
module.exports=plugin;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title:We have a new site!
3+
authors:[rigor789]
4+
---
5+
6+
#This is our first post!
7+
8+
Posts are written in markdown...

‎content/docs/en/_toc.json‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"name":"Introduction",
4+
"type":"main-category",
5+
"children": [
6+
{
7+
"name":"Welcome",
8+
"type":"link",
9+
"children": []
10+
}
11+
]
12+
}
13+
]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title:About NativeScript-Vue
3+
contributors:[rigor789]
4+
---
5+
6+
#What is NativeScript?
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title:Installing NativeScript
3+
extends:https://raw.githubusercontent.com/NativeScript/docs/master/docs/start/quick-setup.md
4+
---
5+
6+
#step 1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp