Skip to content

Commit 7df59a7

Browse files
authored
Merge pull request #57 from giladgd/fixDocumentTitle
fix: page title
2 parents 6570e67 + bce807b commit 7df59a7

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

script/component/DocumentPage.js

+21-5
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,31 @@ const DocumentPage = {
2828
this.updateTitle();
2929
}
3030
},
31-
create: function() {
31+
mounted() {
3232
this.updateTitle();
3333
},
3434
methods: {
35-
updateTitle: function() {
36-
const link = this.$t("links").find(link => link.url === this.document);
37-
if (link) {
38-
window.document.title = link.name + " | TypeORM";
35+
getCurrentDocumentName(links = Links) {
36+
for (const link of links) {
37+
if (link.url === this.document)
38+
return link.name;
39+
else if (link.links instanceof Array) {
40+
const res = this.getCurrentDocumentName(link.links);
41+
if (res != null)
42+
return res;
43+
}
3944
}
45+
46+
return null;
47+
},
48+
updateTitle: function() {
49+
const documentName = this.getCurrentDocumentName();
50+
if (!this.document)
51+
document.title = this.$t("title");
52+
else if (documentName)
53+
window.document.title = documentName + " | TypeORM";
54+
else
55+
document.title = this.$t("title");
4056
}
4157
},
4258
components: {

script/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,5 @@ new Vue({
4141
},
4242
mounted: function () {
4343
i18n.locale = $cookies.get("locale") || "en";
44-
document.title = this.$t("title");
4544
}
4645
});

style/app.css

+4
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ img {
297297
height: auto;
298298
}
299299

300+
.DocSearch mark {
301+
padding: initial;
302+
}
303+
300304
@media (prefers-color-scheme: dark) {
301305
body {
302306
background-color: #18191a;

0 commit comments

Comments
 (0)