个人的 minimal-mistakes 配置记录

记录一下个人的 minimal-mistakes 配置

Modifty

Change font size

assets\css\main.scss

html {
    font-size: 12px; // change to whatever

    @include breakpoint($medium) {
        font-size: 14px; // change to whatever
    }

    @include breakpoint($large) {
        font-size: 16px; // change to whatever
    }

    @include breakpoint($x-large) {
        font-size: 18px; // change to whatever
    }
}

Delete right padding of post

assets\css\main.scss

.page {
    @include breakpoint($large) {
        padding-right: 0;
    }

    @include breakpoint($x-large) {
        padding-right: 0;
    }
}

Add line number to code chunk

_config.yml

# Markdown Processing
kramdown:
...
  syntax_highlighter_opts:
    block:
      line_numbers: true

Add copy button to code chunk

Refer to https://github.com/iBug/iBug-source/commit/eb0180ae9eaa2d3d90c25b9c49cfb0e82fcc5e84

_includes/head.html

<script src="/assets/js/clipboard.js" async defer></script>

_sass\minimal-mistakes\_page.scss

  pre {
    .copy-button {
      position: absolute;
      top: 0.5em;
      right: 0.5em;
      z-index: 1;
      background: none;
      border: none;
      border-radius: 0.1em;
      padding: 0.2em 0.5em;
      color: white;
      opacity: 0.1;
      transition: color 0.25s linear, opacity 0.25s linear;

      &:hover {
        opacity: 1;
      }

      &:before {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 2;
      }
    }

    &:hover .copy-button {
      opacity: 0.6;

      &:hover {
        opacity: 1;
      }
    }
  }

assets/js/clipboard.js

$(document).ready(function() {
  const copyText = function(text) {
    const isRTL = document.documentElement.getAttribute('dir') == 'rtl';

    var textarea = document.createElement('textarea');
    // Prevent zooming on iOS
    textarea.style.fontSize = '12pt';
    // Reset box model
    textarea.style.border = '0';
    textarea.style.padding = '0';
    textarea.style.margin = '0';
    // Move element out of screen horizontally
    textarea.style.position = 'absolute';
    textarea.style[isRTL ? 'right' : 'left'] = '-9999px';
    // Move element to the same position vertically
    let yPosition = window.pageYOffset || document.documentElement.scrollTop;
    textarea.style.top = yPosition + "px";

    textarea.setAttribute('readonly', '');
    textarea.value = text;
    document.body.appendChild(textarea);

    let success = true;
    try {
      textarea.select();
      success = document.execCommand("copy");
    } catch {
      success = false;
    }
    textarea.parentNode.removeChild(textarea);
    return success;
  };

  const copyButtonEventListener = function(event) {
    const thisButton = event.target;

    // Locate the <code> element
    let codeBlock = thisButton.nextElementSibling;
    while (codeBlock && codeBlock.tagName.toLowerCase() !== 'code') {
      codeBlock = codeBlock.nextElementSibling;
    }
    if (!codeBlock) {
      // No <code> found - wtf?
      throw new Error("No code block found beside this button. This is unexpected.");
    }
    return copyText(codeBlock.innerText);
  };

  $(".page__content pre > code").each(function() {
    // Locate the <pre> element
    const container = $(this).parent();
    var copyButton = document.createElement("button");
    copyButton.title = "Copy to clipboard";
    copyButton.className = "copy-button";
    copyButton.innerHTML = '<i class="far fa-copy"></i>';
    copyButton.addEventListener("click", copyButtonEventListener);
    container.prepend(copyButton);
  });
});

Disable scroll bar in code block

_sass\minimal-mistakes\_page.scss

  ::-webkit-scrollbar {
    display: none;
  }

最终这个也不想用了……在本地构建就可以看到复制按钮,但是 github pages 上不知道为什么看不到

不想研究了

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Minimal Mistakes个人主页是一个用于个人或专业用途的响应式网页模板。它提供了一种简单、干净和直观的设计风格,适用于各种不同的需求。 首先,Minimal Mistakes的布局简洁明了,没有多余的装饰或复杂的设计元素,使得页面易于阅读和导航。页面上的内容以有序的方式呈现,帮助用户更快地找到需要的信息。 其次,Minimal Mistakes提供了多种可自定义的选项,以满足不同用户的需求。用户可以轻松地更改网页的颜色、背景、字体和其他样式,以适应自己的品牌或个人偏好。此外,它还可以集成各种插件和功能,例如博客、作品集、社交媒体链接等,以展示个人或专业成果。 此外,Minimal Mistakes个人主页还具有高度的可扩展性。用户可以根据需要添加或删除页面和部分。此外,该模板还兼容多种浏览器和移动设备,确保页面在不同平台上的显示和功能都能良好运作。 最后,Minimal Mistakes采用了响应式设计,意味着页面将根据用户的设备大小和屏幕分辨率自动适应。这使得用户可以在不同设备上无缝浏览和访问个人主页,无需担心兼容性问题。 总之,Minimal Mistakes个人主页是一个简洁、灵活和易于定制的网页模板,适用于个人或专业用途。它提供了出色的可读性和导航,同时具有高度的可扩展性和响应性。无论是展示个人作品还是个人品牌,Minimal Mistakes都是一个优秀的选择。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值