{#
Copyright (C) SPREAD WORKS Inc. All Rights Reserved.
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}
{% set body_class = 'tabacms_post_page' %}
{# 投稿データの取得 #}
{% set post = TabaCMSPost() %}
{% set share_title = post.getTitle|raw|nl2br %}
{% set breadcrumbs = [{'name': 'ニュース', 'route': '/news'}, {'name': post.getTitle|raw|nl2br}] %}
{% if post.getThumbnail is not empty %}
{% set share_media = asset(post.getThumbnail,'save_image') %}
{% else %}
{% set share_media = asset('assets/img/top-page/FV.webp') %}
{% endif %}
{% block javascript %}
{{ TabaCMSAsset('script.js','script')|raw }}
{{ post.getScript|raw }}
<script>
{# MEMO: post.getURLというメソッドによりtabaのプレビュー画面でエラーが発生していた為、jsからURLを渡す形に修正 #}
const share_title = "{{share_title}}";
const share_media = "{{share_media}}"
const share_url = window.location.href;
$(function () {
$(document).ready(function () {
var sns = ["line", "twitter", "facebook", "pinterest"];
$.each(sns,function(index,value){
switch (value){
case "line" :
var line_share_url = `https://social-plugins.line.me/lineit/share?url=${share_url}%0a${share_title}`;
$('.'+ value ).attr('href', line_share_url);
break;
case "twitter" :
var twitter_share_url = `https://twitter.com/intent/tweet?url=${share_url}&text=${share_title}`;
$('.'+ value ).attr('href', twitter_share_url);
break;
case "facebook" :
var facebook_share_url = `https://www.facebook.com/sharer/sharer.php?u=${share_url}`;
$('.'+ value ).attr('href', facebook_share_url);
break;
case "pinterest" :
var pinterest_share_url = `http://pinterest.com/pin/create/button/?url=${share_url}&media=${share_media}&description=${share_title}`;
$('.'+ value ).attr('href', pinterest_share_url);
break;
}
})
});
$(document).ready(function () {
$('#js-button-copy').attr('data-url',share_url);
});
$('#js-button-copy').click(function () {
const url = $(this).data('url');
navigator.clipboard.writeText(url);
});
});
</script>
{% endblock javascript %}
{% block stylesheet %}
{{ TabaCMSAsset('style.css','style')|raw }}
{% endblock stylesheet %}
{% block main %}
<section class="pt-20 md:pt-16">
{{ include('Block/breadcrumb.twig') }}
</section>
<section class="px-6">
<div class="mx-auto w-full max-w-[37rem]">
<div class="mx-auto grid gap-6 leading-normal">
<h1 class="text-2xl font-light tracking-widest md:text-xl">
<span class="sr-only">タイトル:</span>
{{ post.getTitle|raw|nl2br }}
</h1>
<time datetime="{{ post.getPublicDate|date('Y-m-d') }}" class="text-right text-sm tracking-wider">
<span class="sr-only">投稿日:</span>
{{ post.getPublicDate|date('Y.m.d') }}
</time>
</div>
{% if post.getThumbnail is not empty %}
<div class="mt-16 md:mt-10">
<img src="{{ asset(post.getThumbnail,'save_image') }}" class="w-full">
</div>
{% endif %}
<div class="mt-20 pb-[7.5rem] md:text-sm md:mt-6">
{{ post.getBody|raw|nl2br }}
</div>
</div>
</section>
<section class="px-6 pb-[7.5rem] md:pb-20">
<h2 class="font-medium leading-normal text-center text-base">記事をシェアする</h2>
<div class="flex justify-center items-center mt-6 gap-6">
<a class="line" rel="nofollow noopener" target="_blank">
<img src="{{asset('assets/icon/LINE_LOGO.svg')}}" alt="LINEのロゴ" class="w-[2.1rem]">
</a>
<a class="twitter" rel="nofollow noopener" target="_blank">
<img src="{{asset('assets/icon/X_LOGO.svg')}}" alt="Xのロゴ" class="w-7">
</a>
<a class="facebook" rel="nofollow noopener" target="_blank">
<img src="{{asset('assets/icon/FB_LOGO.svg')}}" alt="FaceBookのロゴ" class="w-[2.1rem]">
</a>
<a class="pinterest" rel="nofollow noopener" target="_blank">
<img src="{{asset('assets/icon/Pinterest_LOGO.svg')}}" alt="Pinterestのロゴ" class="w-[2.1rem]">
</a>
<button id="js-button-copy" class="relative">
<img src="{{asset('assets/icon/share.svg')}}" alt="コピー" class="w-[2.1rem]">
</button>
</div>
<a href="/news" class="md:w-full w-80 border grid place-items-center h-11 mx-auto mt-20 text-sm rounded-[0.18rem] hover">
ニュース一覧に戻る
</a>
</section>
{% endblock %}