Skip to content

Commit 0f6f4ec

Browse files
committedOct 12, 2019
enhanced article styles, and profile features
1 parent bbe5716 commit 0f6f4ec

File tree

6 files changed

+164
-16
lines changed

6 files changed

+164
-16
lines changed
 

‎_config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
# Menu setting | format = title_name: link_url
2020
menu:
2121
PAGE: /page
22+
# Social media links
23+
socials:
24+
github: "https://github.com/TriDiamond"
25+
twitter: "https://twitter.com/TriDiamond6"
26+
stackoverflow: "https://stackoverflow.com/users/7602324/tridiamond?tab=profile"
2227

2328
# Enable table of content
2429
TOC: true

‎layout/_partial/post/article.ejs

+5
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
<img src="<%- theme.avatar %>" height=300 width=300></img>
9292
<p><%- config.author %></p>
9393
<span><%- theme.descriptionOne %></span>
94+
<dl>
95+
<dd><a href="<%- theme.socials.github %>" target="_blank"><span class=" iconfont icon-github"></span></a></dd>
96+
<dd><a href="<%- theme.socials.twitter %>" target="_blank"><span class=" iconfont icon-twitter"></span></a></dd>
97+
<dd><a href="<%- theme.socials.stackoverflow %>" target="_blank"><span class=" iconfont icon-stack-overflow"></span></a></dd>
98+
</dl>
9499
</div>
95100
<ul>
96101
<li><a href="/"><%- site.posts.length %> <p>文章</p></a></li>

‎layout/_partial/screen.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<% } %>
5656
<div class="md-content animated fadeIn">
5757
<% if (theme.html_truncate.enable) { %>
58-
<%- htmlTruncate(first.content, theme.html_truncate.coverLength, {
58+
<%- htmlTruncate(first.content, first.preview || theme.html_truncate.coverLength, {
5959
ellipsis: theme.html_truncate.ellipsis,
6060
excludes: theme.html_truncate.excludes,
6161
keepWhitespaces: theme.html_truncate.keepWhitespaces,

‎source/css/dracula.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/* background: #100e17; */
2020
clear: both;
2121
color: #fff;
22-
background: #001628;
22+
background: #100e17;
2323
font-size: 16px;
2424
}
2525

‎source/css/obsidian.css

+127-7
Original file line numberDiff line numberDiff line change
@@ -1332,20 +1332,62 @@ h1.title {
13321332
top: calc(1rem + 61px);
13331333
}
13341334

1335+
.article .sidebar .subbox dl {
1336+
position: relative;
1337+
top: 0;
1338+
left: 0;
1339+
display: grid;
1340+
grid-template-columns: 33% 33% 33%;
1341+
font-weight: 900;
1342+
margin-block-start: 1.2em;
1343+
margin-block-end: 0;
1344+
}
1345+
1346+
.article .sidebar .box .subbox dl dd {
1347+
display: block;
1348+
max-width: 100%;
1349+
text-align: center;
1350+
margin-inline-start: 0;
1351+
line-height: 28px;
1352+
transition: all 800ms linear;
1353+
}
1354+
1355+
.article .sidebar .box .subbox dl dd a:hover,
1356+
.article .sidebar .box .subbox dl dd a span:hover,
1357+
.article .sidebar .box .subbox dl dd:hover {
1358+
color: #100e17;
1359+
}
1360+
1361+
.article .sidebar .box .subbox dl dd:nth-last-of-type(2) {
1362+
padding-top: 2px;
1363+
}
1364+
1365+
.article .sidebar .box .subbox dl dd a,
1366+
.article .sidebar .box .subbox dl dd a span {
1367+
font-size: 28px;
1368+
line-height: 28px;
1369+
padding-top: 0;
1370+
}
1371+
13351372
.article .sidebar .box ul {
13361373
position: relative;
13371374
top: 1.2rem;
13381375
right: -1rem;
13391376
display: grid;
13401377
grid-template-columns: 100px 100px 100px;
1341-
font-weight: 900px;
1378+
font-weight: 900;
13421379
font-size: 18px;
13431380
}
13441381

13451382
.article .sidebar .box ul li {
13461383
display: block;
13471384
max-width: 100%;
13481385
text-align: center;
1386+
border-right: 1px solid rgba(158, 158, 158, 0.16);
1387+
}
1388+
1389+
.article .sidebar .box ul li:last-of-type {
1390+
border-right: none;
13491391
}
13501392

13511393
.article .sidebar .box ul li p {
@@ -1474,6 +1516,13 @@ h1.title {
14741516
border: none;
14751517
}
14761518

1519+
.article p.image-caption {
1520+
color: #9E9E9E;
1521+
width: 100%;
1522+
text-align: center;
1523+
padding-top: 5px;
1524+
}
1525+
14771526
.article-header-wrapper {
14781527
width: 100%;
14791528
height: 500px;
@@ -1753,6 +1802,50 @@ h1.title {
17531802
font-family: operator mono ssm a,operator mono ssm b,operator mono,source code pro,Menlo,Consolas,Monaco,monospace;
17541803
}
17551804

1805+
.md-content p,
1806+
.md-content pre,
1807+
.md-content blockquote {
1808+
margin: 0 0 2em;
1809+
}
1810+
1811+
.md-content h1,
1812+
.md-content h2,
1813+
.md-content h3,
1814+
.md-content h4 {
1815+
margin-top: 1em;
1816+
margin-bottom: 0.8em;
1817+
}
1818+
1819+
.md-content blockquote > p {
1820+
margin: 0;
1821+
}
1822+
1823+
.md-content hr {
1824+
display: block;
1825+
margin-top: 30px;
1826+
margin-bottom: 20px;
1827+
border: 0;
1828+
font-size: 28px;
1829+
font-weight: 300;
1830+
unicode-bidi: isolate;
1831+
margin-block-start: 0.5em;
1832+
margin-block-end: 0.5em;
1833+
margin-inline-start: auto;
1834+
margin-inline-end: auto;
1835+
border: none;
1836+
text-align: center;
1837+
color: rgba(102, 128, 153, 1);
1838+
/*border-top: 1px solid rgba(102, 128, 153, 0.1)*/
1839+
}
1840+
1841+
.md-content hr:before {
1842+
content: "...";
1843+
line-height: 1.4;
1844+
font-style: italic;
1845+
text-indent: 0.6em;
1846+
letter-spacing: 0.6em;
1847+
}
1848+
17561849
#post0 .md-content {
17571850
color:#fff;
17581851
font-size: 16px;
@@ -1935,14 +2028,33 @@ h4 a:hover {
19352028
}
19362029

19372030
.content hr {
1938-
margin-top: 21px;
1939-
margin-bottom: 21px;
2031+
display: block;
2032+
margin-top: 30px;
2033+
margin-bottom: 20px;
19402034
border: 0;
1941-
border-top: 1px solid rgba(102, 128, 153, 0.1)
2035+
font-size: 28px;
2036+
font-weight: 300;
2037+
unicode-bidi: isolate;
2038+
margin-block-start: 0.5em;
2039+
margin-block-end: 0.5em;
2040+
margin-inline-start: auto;
2041+
margin-inline-end: auto;
2042+
border: none;
2043+
text-align: center;
2044+
color: rgba(102, 128, 153, 0.6);
2045+
/*border-top: 1px solid rgba(102, 128, 153, 0.1)*/
2046+
}
2047+
2048+
.content hr:before {
2049+
content: "...";
2050+
line-height: 1.4;
2051+
font-style: italic;
2052+
text-indent: 0.6em;
2053+
letter-spacing: 0.6em;
19422054
}
19432055

19442056
.content p {
1945-
margin: 0 0 .8em;
2057+
margin: 0 0 2em;
19462058
}
19472059

19482060
.content ul,
@@ -1994,11 +2106,19 @@ h4 a:hover {
19942106
font-size: 0.9rem;
19952107
}
19962108

2109+
.content img {
2110+
border-radius: 8px;
2111+
}
2112+
19972113
code,
19982114
pre {
19992115
font-family: "Source Code Pro", monospace
20002116
}
20012117

2118+
pre {
2119+
margin: 2em 0;
2120+
}
2121+
20022122
code {
20032123
background: rgba(99, 99, 99, 0.07);
20042124
background: #b2fefa;
@@ -2008,7 +2128,7 @@ code {
20082128
overflow-wrap: break-word;
20092129
word-wrap: break-word;
20102130
padding: .1rem .3rem .2rem;
2011-
border-radius: .2rem;
2131+
border-radius: 8px;
20122132
opacity: 0.9;
20132133
}
20142134

@@ -2020,7 +2140,7 @@ code {
20202140

20212141
.content blockquote {
20222142
color: #656565;
2023-
margin: 0 0 1.1em;
2143+
margin: 0 0 2em;
20242144
border-left: 3px solid var(--code-gradient-light);
20252145
border-left-width: 6px;
20262146
background-color: rgba(119, 119, 119, 0.05);

‎source/js/obsidian.js

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Watch the TOC during scroll and fill in active status
3+
* @param {} menuSelector
4+
* @param {*} options
5+
*/
16
function scrollSpy(menuSelector, options) {
27
var menu = $(menuSelector);
38
if(!menu)
@@ -26,15 +31,27 @@ function scrollSpy(menuSelector, options) {
2631
for(var target = menu.find("[href='#" + id + "']");
2732
target.length && !target.is(menu);
2833
target = target.parent()) {
29-
if(target.is("li"))
30-
newActive.push(target[0]);
31-
}
34+
if(target.is("li"))
35+
newActive.push(target[0]);
36+
}
3237
active = $(newActive).addClass(activeClassName).trigger("scrollspy");
3338
lastId = id;
3439
}
3540
});
3641
}
3742

43+
/**
44+
* Buidling the caption html in an aritle
45+
*/
46+
function buildImgCaption () {
47+
var images = $('.content').find('img');
48+
49+
images.each(function () {
50+
var caption = $(this).attr('alt');
51+
$('.content').find("[alt='" + caption + "']").parent().append('<p class="image-caption">"' + caption + '"</p>');
52+
});
53+
}
54+
3855
var Home = location.href,
3956
Pages = 4,
4057
xhr,
@@ -119,19 +136,17 @@ var Obsidian = {
119136
case 'push':
120137
history.pushState(state, title, url)
121138
$('#preview').html($(data).filter('#single'));
122-
Obsidian.preview();
123139
break;
124140
case 'replace':
125141
history.replaceState(state, title, url)
126142
$('#preview').html($(data).filter('#single'));
127-
Obsidian.preview();
128143
break;
129144
}
130145
document.title = title;
131146
$('#preview').html($(data).filter('#single'))
132147
switch (flag) {
133148
case 'push':
134-
Obsidian.preview()
149+
Obsidian.preview();
135150
break;
136151
case 'replace':
137152
Obsidian.initArticleJs();
@@ -168,6 +183,7 @@ var Obsidian = {
168183
'position': 'static',
169184
// 'overflow-y': 'auto'
170185
});
186+
console.log('preivew', 'initArticleJs')
171187
Obsidian.initArticleJs();
172188
}, 500);
173189
}, 0);
@@ -245,7 +261,8 @@ var Obsidian = {
245261
});
246262
Obsidian.setCodeRowWithLang();
247263
Obsidian.tocSpy(200);
248-
initValine()
264+
initValine();
265+
buildImgCaption();
249266
},
250267
setCodeRowWithLang: function() {
251268
// Get the programming type of the current code block
@@ -635,6 +652,7 @@ $(function() {
635652
}
636653
if ($('.article').length) {
637654
Obsidian.tocSpy(200);
655+
buildImgCaption();
638656
}
639657
initialTyped();
640658
Obsidian.setCodeRowWithLang();

0 commit comments

Comments
 (0)
Please sign in to comment.