Một số lưu ý khi chỉnh sửa theme cho Blogger
Không hợp Feature post ở trang Post Detail
Bạn sẽ thêm điều kiện cond='data:view.isHomepage'.
VD:
<b:section class='main' id='page_body' name='Page Body' showaddelement='false'>
<b:widget cond='data:view.isHomepage' id='FeaturedPost1' locked='true' title='' type='FeaturedPost' visible='true'>
<b:widget-settings>
<b:widget-setting name='showSnippet'>true</b:widget-setting>
<b:widget-setting name='showPostTitle'>true</b:widget-setting>
<b:widget-setting name='showFirstImage'>true</b:widget-setting>
<b:widget-setting name='useMostRecentPost'>true</b:widget-setting>
</b:widget-settings>
</b:section>
Thêm Syntax Highlighter
Bạn tham khảo ở trang: https://highlightjs.org/usage/
Thêm đoạn code sau trước thẻ body
<link href='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/styles/default.min.css' rel='stylesheet'/>
<script src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js'/>
<!-- and it's easy to individually load additional languages -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/languages/go.min.js'/>
<script type='text/javascript'>
document.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll('pre code').forEach((el) => {
hljs.highlightElement(el);
});
});
</script>
Khi soạn thảo bài viết, bạn chuyển sang chế độ HTML rồi soạn thảo theo cách sau:
<pre><code lang="csharp">Console.WriteLine("Helllo World");
</code></pre>
Nhận xét
Đăng nhận xét