【问题标题】:Not able to find pre-defined sass variables in Jekyll project无法在 Jekyll 项目中找到预定义的 sass 变量
【发布时间】:2019-07-17 17:10:12
【问题描述】:

我是 Jeykll 和 Sass 的新手,有一个简短的问题。在启动新项目时的预构建主题中,这些变量在哪里定义?

我似乎无法在整个构建过程中发现他们意识到这一点。 这是在 _sass/layout.scss 目录中。

 */
.site-header {
    border-top: 5px solid $grey-color-dark;
    border-bottom: 1px solid $grey-color-light;
    min-height: 56px;

    // Positioning context for the mobile navigation icon
    position: relative;
}

.site-title {
    font-size: 26px;
    line-height: 56px;
    letter-spacing: -1px;
    margin-bottom: 0;
    float: left;

    &,
    &:visited {
        color: $grey-color-dark;
    }
}

.site-nav {
    float: right;
    line-height: 56px;

    .menu-icon {
        display: none;
    }

    .page-link {
        color: $text-color;
        line-height: $base-line-height;

        // Gaps between nav items, but not on the first one
        &:not(:first-child) {
            margin-left: 20px;
        }
    }

    @include media-query($on-palm) {
        position: absolute;
        top: 9px;
        right: 30px;
        background-color: $background-color;
        border: 1px solid $grey-color-light;
        border-radius: 5px;
        text-align: right;

        .menu-icon {
            display: block;
            float: right;
            width: 36px;
            height: 26px;
            line-height: 0;
            padding-top: 10px;
            text-align: center;

            > svg {
                width: 18px;
                height: 15px;

                path {
                    fill: $grey-color-dark;
                }
            }
        }

        .trigger {
            clear: both;
            display: none;
        }

        &:hover .trigger {
            display: block;
            padding-bottom: 5px;
        }

        .page-link {
            display: block;
            padding: 5px 10px;
        }
    }
}



/**
 * Site footer
 */
.site-footer {
    border-top: 1px solid $grey-color-light;
    padding: $spacing-unit 0;
}

.footer-heading {
    font-size: 18px;
    margin-bottom: $spacing-unit / 2;
}

.contact-list,
.social-media-list {
    list-style: none;
    margin-left: 0;
}

.footer-col-wrapper {
    font-size: 15px;
    color: $grey-color;
    margin-left: -$spacing-unit / 2;
    @extend %clearfix;
}

.footer-col {
    float: left;
    margin-bottom: $spacing-unit / 2;
    padding-left: $spacing-unit / 2;
}

.footer-col-1 {
    width: -webkit-calc(35% - (#{$spacing-unit} / 2));
    width:         calc(35% - (#{$spacing-unit} / 2));
}

.footer-col-2 {
    width: -webkit-calc(20% - (#{$spacing-unit} / 2));
    width:         calc(20% - (#{$spacing-unit} / 2));
}

.footer-col-3 {
    width: -webkit-calc(45% - (#{$spacing-unit} / 2));
    width:         calc(45% - (#{$spacing-unit} / 2));
}

@include media-query($on-laptop) {
    .footer-col-1,
    .footer-col-2 {
        width: -webkit-calc(50% - (#{$spacing-unit} / 2));
        width:         calc(50% - (#{$spacing-unit} / 2));
    }

    .footer-col-3 {
        width: -webkit-calc(100% - (#{$spacing-unit} / 2));
        width:         calc(100% - (#{$spacing-unit} / 2));
    }
}

@include media-query($on-palm) {
    .footer-col {
        float: none;
        width: -webkit-calc(100% - (#{$spacing-unit} / 2));
        width:         calc(100% - (#{$spacing-unit} / 2));
    }
}



/**
 * Page content
 */
.page-content {
    padding: $spacing-unit 0;
}

.page-heading {
    font-size: 20px;
}

.post-list {
    margin-left: 0;
    list-style: none;

    > li {
        margin-bottom: $spacing-unit;
    }
}

.post-meta {
    font-size: $small-font-size;
    color: $grey-color;
}

.post-link {
    display: block;
    font-size: 24px;
}



/**
 * Posts
 */
.post-header {
    margin-bottom: $spacing-unit;
}

.post-title {
    font-size: 42px;
    letter-spacing: -1px;
    line-height: 1;

    @include media-query($on-laptop) {
        font-size: 36px;
    }
}

.post-content {
    margin-bottom: $spacing-unit;

    h2 {
        font-size: 32px;

        @include media-query($on-laptop) {
            font-size: 28px;
        }
    }

    h3 {
        font-size: 26px;

        @include media-query($on-laptop) {
            font-size: 22px;
        }
    }

    h4 {
        font-size: 20px;

        @include media-query($on-laptop) {
            font-size: 18px;
        }
    }
}

【问题讨论】:

    标签: ruby sass jekyll


    【解决方案1】:

    注意: Jekyll 已更新,其默认主题 minima 现在位于单独的 gem 中,定义为 there, in _sass/minima.scss


    Look at this, with relative path to site root in default Jekyl site css/main.scss。他们在那里。 在所有定义、导入和处理之后,结果站点中将有css/main.css

    _sass 中的所有内容仅用于导入将转换为 CSS 的真实资产。 _sass 中的 Sass/SCSS 文件与其他任何地方的区别在于 _sass 中的文件不是直接编译的,而是直接放在它们所在的位置并等待导入。每个可能可重用的 Sass 部分都应该在 _sass 中,这就是 Sass 部分和整个系统的设计目的。如果您使用大量 Sass 库 (like I do, and it's still a mess) 并且不希望修改它们以放入您的资产中,这将特别有用。

    所有其他文件(不在_sass中),但是会被处理成对应的*.css文件,为了区分文件进行处理,Jekyll要求这些文件有一个YAML front-matter ,通常是

    ---
    ---
    
    // Sass code here
    

    (我曾经在 Sass 中使用 Liquid 来嵌入变量,但是 that feature vanished after some updates,所以现在资产中的非空 YFM 已经没有用了)。

    【讨论】:

    • 我……其实对此有点困惑。我的意思是,我可以在 GitHub 上看到 sass 变量。但是我不明白为什么当我将项目的那一部分拉到我的本地时没有克隆它。帮忙?
    • @sabaeus 这个模板在运行jekyll new sitename 时被复制过来。你这样做了吗?
    • @sabaeus 嗯,模板其实在lib/site_template
    • 看看这个链接坏了。
    • @MartinMarconcini 抱歉耽搁了!我休了一年的 Stack Exchange :) 修复它。
    猜你喜欢
    • 1970-01-01
    • 2014-04-20
    • 2016-08-07
    • 1970-01-01
    • 2014-03-21
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 2014-11-13
    相关资源
    最近更新 更多