Skip to content

Commit 971cceb

Browse files
committed
Complete made-with fixing.
1 parent 996581f commit 971cceb

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed
Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
import { Component, Input, OnInit } from '@angular/core';
2+
import { SettingsService } from '../services/settings.service';
3+
4+
import { join } from '../shared/utils';
25

36
@Component({
4-
selector: 'made-with-docspa', // tslint:disable-line
5-
template: `
7+
selector: 'made-with-docspa', // tslint:disable-line
8+
template: `
69
<ng-template #noUrl>
7-
by
10+
by
811
<ng-content></ng-content>
912
<slot></slot>
1013
{{name}}
1114
</ng-template>
1215
<span [style.font-size.em]="size">
1316
<ng-container *ngIf="url && url.length > 0; else noUrl">
14-
By <a [attr.href]="url" target="_blank" [style.color]="color" rel="noopener">
17+
作者: <a [attr.href]="url" target="_blank" [style.color]="color" rel="noopener">
1518
<ng-content></ng-content>
1619
<slot></slot>
1720
{{name}}
18-
</a>
21+
</a>({{url}})
1922
</ng-container>
2023
</span>
2124
`,
22-
styles: [`
25+
styles: [`
2326
:host {
2427
span {
2528
a {
@@ -31,23 +34,33 @@ import { Component, Input, OnInit } from '@angular/core';
3134
`]
3235
})
3336
export class MadeWithDocSPAComponent implements OnInit {
34-
static readonly is = 'made-with-docspa';
37+
static readonly is = 'made-with-docspa';
3538

36-
@Input()
37-
public name: string;
39+
@Input()
40+
public color = 'red';
3841

39-
@Input()
40-
public url: string;
42+
@Input()
43+
public size = 0.5;
4144

42-
@Input()
43-
public color = 'red';
45+
constructor (
46+
private settings: SettingsService
47+
) {}
4448

45-
@Input()
46-
public size = 0.5;
49+
get bookPath () {
50+
return this.settings.bookPath;
51+
}
4752

48-
ngOnInit() {
49-
if (!this.name || this.name.length === 0) {
50-
console.error(`Name attribute must be provided!`);
53+
get name () {
54+
return this.bookPath.replace(/^\//, '').replace(/\/$/, '').split('/')[1];
55+
}
56+
57+
get url () {
58+
return join('https://', this.bookPath.replace(/\/$/, '').replace(/\/[^\/]{1,254}$/, ''));
59+
}
60+
61+
ngOnInit() {
62+
if (!this.name || this.name.length === 0) {
63+
console.error(`Name attribute must be provided!`);
64+
}
5165
}
52-
}
5366
}

src/app/read/read.page.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<a id="page-top"></a>
22

3-
<nav
4-
id="main-nav"
5-
*ngIf="navbarPage"
6-
class="app-nav no-badge">
3+
<nav id="main-nav"
4+
*ngIf="navbarPage"
5+
class="app-nav no-badge">
76
<docspa-md-include [path]="navbarPage" [safe]="true"></docspa-md-include>
87
</nav>
98

src/assets/shared/_footer.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33
---
44

5-
<made-with-docspa url="https://ccna60d.xfoss.com" size="1" name="ccna60d.xfoss.com">
6-
</made-with-docspa>
5+
<made-with-docspa size="1"></made-with-docspa>

src/assets/shared/_navbar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
- [<i class="material-icons github-icon"><object type="image/svg+xml" data="assets/icon/github.svg"></object></i>](https://github.com/gnu4cn/ccna60d)
1+
- [<object type="image/svg+xml" data="assets/icon/github.svg"></object>](https://github.com/gnu4cn/ccna60d)
22

0 commit comments

Comments
 (0)