Skip to content

Instantly share code, notes, and snippets.

@867
867 / blog-nunjucks-news-03.js
Last active Mar 11, 2019
公式ブログ用:gulpfile.js : gulp-fs
View blog-nunjucks-news-03.js
'use strict';
const gulp = require('gulp');
const nunjucks = require('gulp-nunjucks-render');
const data = require('gulp-data');
const fs = require('fs');
const paths = {
'src' : {
'root' : 'src/',
'template' : 'src/template/',
@867
867 / blog-nunjucks-news-02.njk
Last active Mar 11, 2019
公式ブログ用:Nunjucks-news2
View blog-nunjucks-news-02.njk
{% set news_category1 = 'pro' %}
{% set news_category2 = '' %}
{% set news_current = 1 %}
{% block contents -%}
<section>
<header>
<h2>ニュース>製品情報</h2>
</header>
@867
867 / blog-nunjucks-news-01.njk
Last active Mar 11, 2019
公式ブログ用:Nunjucks-news1
View blog-nunjucks-news-01.njk
{% set news_category1 = '' %}
{% set news_category2 = '' %}
{% set news_amount = 5 %}
{% block contents -%}
<section>
<header>
<h2>ニュース</h2>
</header>
<ul>
@867
867 / blog-nunjucks-template.html
Last active Jul 13, 2018
公式ブログ用:Nunjucks : html/index.html
View blog-nunjucks-template.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>グランドトップ | sample site</title>
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="description" content="GTディスクリプション">
<meta name="keywords" content="キーワード1,キーワード2">
<meta name="viewport" content="width=device-width, initial-scale=1">
@867
867 / blog-nunjucks-template-03.njk
Last active Jul 12, 2018
公式ブログ用:Nunjucks : partial/_dochead.njk
View blog-nunjucks-template-03.njk
{%- if pageT -%}
{%- set title = pageT + ' | ' + data.sitename -%}{%- else -%}
{%- set title = data.sitename -%}
{%- endif -%}
{%- if pageD -%}
{%- set description = pageD -%}{%- else -%}
{%- set description = data.meta.description -%}
{%- endif -%}
{%- if pageK -%}
{%- set keywords = pageK -%}{%- else -%}
@867
867 / blog-nunjucks-template-02.njk
Last active Jul 13, 2018
公式ブログ用:Nunjucks : page/index.njk
View blog-nunjucks-template-02.njk
{% extends 'layout/_default.njk' %}
{% set pageT = 'グランドトップ' %}
{% set pageD = 'GTディスクリプション' %}
{% set pageK = 'キーワード1,キーワード2' %}
{% set ogType = 'website' %}
{% block contents -%}
<p>グランドトップのコンテンツ</p>
{%- endblock %}
@867
867 / blog-nunjucks-template-01.njk
Created Jul 12, 2018
公式ブログ用:Nunjucks : layout/_default.njk
View blog-nunjucks-template-01.njk
<!DOCTYPE html>
<html lang="ja">
<head>
{% include 'partial/site/_dochead.njk' -%}
<!-- GTMタグなど -->
</head>
<body>
<!-- GTMタグなど -->
{% include 'partial/site/_header.njk' -%}
{% block contents -%}{%- endblock %}
@867
867 / blog-nunjucks-parts03.js
Last active Jul 12, 2018
公式ブログ用:gulpfile.js : gulp-beautify
View blog-nunjucks-parts03.js
// set:beautify_option
const beautify_option = {
'indent_size': 2
}
// task:nunjucks
gulp.task('nunjucks', function(){
return gulp.src(paths.src.html + '**/*.njk')
.pipe(data(function(){
return require(paths.src.json);
@867
867 / blog-nunjucks-parts02.js
Last active Jul 12, 2018
公式ブログ用:gulpfile.js : gulp-data
View blog-nunjucks-parts02.js
// task:nunjucks
gulp.task('nunjucks', function(){
return gulp.src(paths.src.html + '**/*.njk')
.pipe(data(function(){
return require(paths.src.json);
}))
.pipe(nunjucks({
path: paths.src.template
}))
.pipe(gulp.dest(paths.dest.root))
@867
867 / blog-nunjucks-site.json
Created Jul 9, 2018
公式ブログ用:site.json
View blog-nunjucks-site.json
{
"data" : {
"sitename" : "sample site",
"meta" : {
"description" : "",
"keywords" : ""
},
"og" : {
"type" : "article",
"image" : "/assets/img/ogp/og-def-01.png"