Commit dffe0884 authored by Kuro Usada's avatar Kuro Usada
Browse files

#8 fixed

parent 9ce195dc
......@@ -29,7 +29,8 @@ exports.createPages = ({ actions, graphql }) => {
templateKey
title
draft
date(formatString: "MMMM DD, YYYY")
date
locale
}
excerpt(format: HTML, truncate: true)
}
......
......@@ -8,6 +8,7 @@ const BlogPostPreview = ({ entry, widgetFor }) => (
description={entry.getIn(['data', 'description'])}
tags={entry.getIn(['data', 'tags'])}
date={entry.getIn(['data', 'date'])}
locale={entry.getIn(['data', 'locale'])}
title={entry.getIn(['data', 'title'])}
draft={entry.getIn(['data', 'draft'])}
/>
......
import React from "react";
export function formatString(date) {
return new Intl.DateTimeFormat('ja-JP', { year: 'numeric', month: 'long', day: 'numeric', weekday: 'short', hour: 'numeric', minute: 'numeric' }).format(date)
export function formatString(date, locale) {
return new Intl.DateTimeFormat(locale, { year: 'numeric', month: 'long', day: 'numeric', weekday: 'short', hour: 'numeric', minute: 'numeric' }).format(date)
}
export default class DateTime extends React.Component {
render() {
const { date } = this.props;
const { date, locale } = this.props;
if (!date) {
return null;
}
const datetime = formatString(date instanceof Date ? date : new Date(date));
const datetime = formatString(date instanceof Date ? date : new Date(date), locale || 'en-US');
return (
<time className="published-date" dateTime={datetime}>{datetime}</time>
......
......@@ -33,6 +33,7 @@ const TemplateWrapper = ({ children }) => (
/>
<link rel="canonical" href={`${data.site.siteMetadata.siteUrl}/`} />
<link rel="alternate" hreflang="ja" href={`${data.site.siteMetadata.siteUrl}/`} />
<link rel="alternate" hreflang="en" href={`${data.site.siteMetadata.siteUrl}/`} />
<link rel="alternate" hreflang="x-default" href={`${data.site.siteMetadata.siteUrl}/`} />
<link
......
import React from "react";
import { Link } from "gatsby";
import DateTime from "./DateTime"
export default class PostCard extends React.Component {
render() {
const { post } = this.props;
return (
<div>
<div className="post-card">
<p>
<Link className="has-text-primary is-size-4" to={post.fields.slug}>
{post.frontmatter.title}
</Link>
<span> &bull; </span>
<small>{post.frontmatter.date}</small>
<DateTime date={post.frontmatter.date} locale={post.frontmatter.locale} />
</p>
<div className="excerpt" dangerouslySetInnerHTML={{ __html: post.excerpt}}>
</div>
......
......@@ -98,6 +98,12 @@ time {
margin-bottom:1em;
}
.post-card .published-date {
display:inline;
text-align:left;
margin-bottom:auto;
}
.content .note {
padding:1em;
border: 2px solid whitesmoke;
......
......@@ -4,11 +4,13 @@ title: Goを使ってDLLをクロスコンパイル on Linux
date: 2017-11-30T18:00:00.000Z
description: Cross compile DLL using Golang on Linux
draft: false
locale: ja-JP
tags:
- golang
- tech
- ukagaka
- linux
- lang:ja
---
[mattn](https://mattn.kaoriya.net/) さんによる「[Golang で Windows の DLL を作る方法](https://mattn.kaoriya.net/software/lang/go/20160921010820.htm)」という記事を参考に、cgo を使って Linux 上で DLL をクロスコンパイルします。
Go を使えば、Windows なしで[伺か](https://ja.wikipedia.org/wiki/伺か)の SHIORI.DLL を作成することができます。ので、作ります。
......
......@@ -4,9 +4,11 @@ title: UbuntuのrepoにあるWine 1.6のSSL関連の不具合を治すには
date: 2017-10-20T02:33:00.000Z
description: How to fix Wine's SSL problems by installing latest one
draft: true
locale: ja-JP
tags:
- linux
- tech
- lang:ja
---
<!-- more -->
......
---
templateKey: blog-post
title: 【東京ディズニーシー】徒歩で行く時の最短ルート!
locale: ja-JP
date: 2017-10-20T02:33:00.000Z
description: The firstest way to Tokyo Disney Sea by Walking
draft: false
tags:
- disney
- tds
- lang:ja
---
ディズニーリゾートラインは音楽や装飾が気分を盛り上げてくれますが、片道260円(往復520円)は結構な出費ですよね。
でも!舞浜駅からディズニーシーまでは約15分歩くだけで着いちゃうんです。
......
......@@ -4,9 +4,11 @@ title: 【東京ディズニーシー】電車で行く時の最短ルート!
date: 2017-05-23T16:55:00.000Z
description: The firstest way to Tokyo Disney Sea by Train
draft: false
locale: ja-JP
tags:
- disney
- tds
- lang:ja
---
東京ディズニーリゾートへ行く時、なんとなく来た電車に乗って、なんとなくみんなが進む方向に進んでいませんか?<br>
今回は東京駅からディズニーシーのノース・エントランスへ行く時の最短ルートをお教えします!<br>
......
---
templateKey: blog-post
title: ぼっちディズニーマニアがサンリオピューロランドへ行った話
locale: ja-JP
date: 2018-08-14T07:51:00.000Z
description: A Disney mania visited Sanrio Puroland
draft: false
tags:
- lang:ja
- puroland
---
日本三大テーマパークのうち、東京ディズニーリゾートとユニバーサル・スタジオ・ジャパンはいいとして、最後の一つを何にするかで友人と揉めたことがみなさんも一度はあると思います。
......
---
templateKey: blog-post
title: オフラインでも懐かしいあの頃に戻る方法
locale: ja-JP
date: 2017-10-31T09:44:00.000Z
description: How to get back old times offline
draft: false
tags:
- lang:ja
- tech
---
個人運営の『ホームページ』が幅を利かせていた懐かしのあの頃。
......
---
templateKey: blog-post
title: ディズニーシーではこれを食え!
locale: ja-JP
date: 2017-11-03T00:51:00.000Z
description: Eat them in Tokyo DisneySea
draft: false
tags:
- lang:ja
- disney
- tds
- food
......
---
templateKey: blog-post
title: ディズニーシーではこれを飲め!
locale: ja-JP
date: 2017-11-01T15:01:00.000Z
description: Drink them in Tokyo DisneySea
draft: false
tags:
- lang:ja
- disney
- tds
- food
......
---
templateKey: blog-post
title: ディズニー・フードの鉄則
locale: ja-JP
date: 2017-10-31T15:51:00.000Z
description: Disney food dogma
draft: false
tags:
- lang:ja
- disney
- tds
- tdl
......
---
templateKey: blog-post
title: ローグライクのターン制ゲームループ
locale: ja-JP
date: 2018-01-02T14:19:00.000Z
description: A turn-based gameloop for roguelikes
draft: false
tags:
- lang:ja
- tech
- rl
- python
......
---
templateKey: blog-post
title: 東京ディズニーリゾートに行くなら初夏!な理由
locale: ja-JP
date: 2017-05-25T21:01:00.000Z
description: Why early summer is the best season to go to TDR
draft: false
tags:
- lang:ja
- disney
- tds
- tdl
......
......@@ -20,6 +20,7 @@ export const BlogPostTemplate = ({
tableOfContents,
next,
prev,
locale,
disqusShortname,
disqusConfig,
helmet
......@@ -35,7 +36,7 @@ export const BlogPostTemplate = ({
<h1 className="title is-size-4 has-text-weight-bold is-bold-light">
{title}
</h1>
<DateTime date={date} />
<DateTime date={date} locale={locale} />
{tableOfContents && (<TableOfContents caption="Index" content={tableOfContents} />)}
<PostContent content={content} />
{tags && tags.length ? (
......@@ -106,6 +107,7 @@ BlogPostTemplate.propTypes = {
tableOfContents: PropTypes.string,
prev: PropTypes.object,
next: PropTypes.object,
locale: PropTypes.string,
disqusShortname: PropTypes.string,
disqusConfig: PropTypes.object,
helmet: PropTypes.object
......@@ -120,6 +122,7 @@ const BlogPost = ({ data, pageContext }) => {
url: encodeURI(url),
title: post.frontmatter.title
}
const lang = post.frontmatter.locale.split("-")[0] || site.siteMetadata.lang;
return (
<Layout>
......@@ -131,13 +134,14 @@ const BlogPost = ({ data, pageContext }) => {
date={post.frontmatter.date}
helmet={
<Helmet titleTemplate={`%s | ${site.siteMetadata.title}`}>
<html lang={lang} />
<title>{`${post.frontmatter.title}`}</title>
<meta
name="description"
content={`${post.frontmatter.description}`}
/>
<link rel="canonical" href={url} />
<link rel="alternate" hreflang="ja" href={url} />
<link rel="alternate" hreflang={lang} href={url} />
<link rel="alternate" hreflang="x-default" href={url} />
<meta property="og:title" content={`${post.frontmatter.title}`} />
<meta
......@@ -152,6 +156,7 @@ const BlogPost = ({ data, pageContext }) => {
tableOfContents={post.tableOfContents}
next={next}
prev={prev}
locale={post.frontmatter.locale}
disqusShortname={site.siteMetadata.disqusShortname}
disqusConfig={disqusConfig}
/>
......@@ -179,6 +184,7 @@ export const pageQuery = graphql`
date
title
description
locale
tags
}
html
......@@ -186,6 +192,7 @@ export const pageQuery = graphql`
}
site {
siteMetadata {
lang
title
siteUrl
disqusShortname
......
......@@ -26,6 +26,7 @@ class TagRoute extends React.Component {
/>
<link rel="canonical" href={`${siteUrl}/tags/${tag}`} />
<link rel="alternate" hreflang="ja" href={`${siteUrl}/tags/${tag}`} />
<link rel="alternate" hreflang="en" href={`${siteUrl}/tags/${tag}`} />
<link rel="alternate" hreflang="x-default" href={`${siteUrl}/tags/${tag}`} />
<meta property="og:title" content={`${tag} | ${title}`} />
<meta
......@@ -75,6 +76,7 @@ export const tagPageQuery = graphql`
site {
siteMetadata {
title
lang
siteUrl
}
}
......@@ -93,6 +95,7 @@ export const tagPageQuery = graphql`
}
frontmatter {
title
locale
date(formatString: "MMMM DD, YYYY")
}
}
......
......@@ -14,11 +14,12 @@ collections:
fields:
- {label: "Template Key", name: "templateKey", widget: "hidden", default: "blog-post"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Locale", name: "locale", widget: "select", default: "ja-JP", options: ["ja-JP", "en-US"]}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Description", name: "description", widget: "text"}
- {label: "Draft", name: "draft", widget: "boolean", default: true}
- {label: "Body", name: "body", widget: "markdown"}
- {label: "Tags", name: "tags", widget: "list"}
- {label: "Tags", name: "tags", widget: "list", hint: "Add language tag e.g. 'lang:ja'"}
- name: "pages"
label: "Pages"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment