Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds split blog templates #414

Merged
merged 2 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/cms-cli/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ const ASSET_PATHS = {
__dirname,
'../defaults/email-template.html'
),
'blog-template': path.resolve(__dirname, '../defaults/blog-template.html'),
'blog-listing-template': path.resolve(
__dirname,
'../defaults/blog-listing-template.html'
),
'blog-post-template': path.resolve(
__dirname,
'../defaults/blog-post-template.html'
),
'search-template': path.resolve(
__dirname,
'../defaults/search-template.html'
Expand Down
151 changes: 151 additions & 0 deletions packages/cms-cli/defaults/blog-listing-template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<!--
templateType: blog_listing
isAvailableForNewContent: true
label: Blog listing
-->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{{ content.html_title }}</title>
<meta name="description" content="{{ content.meta_description }}">
{{ standard_header_includes }}
</head>
<body>
<main>

{# Blog author listing #}
{% if blog_author %}
<div>
{% if blog_author.avatar %}
<img src="{{ blog_author.avatar }}" alt="image of blog {{ blog_author.display_name }}">
{% endif %}
<h1>{{ blog_author.display_name }}</h1>
{% if blog_author.bio %}
<p>{{ blog_author.bio }}</p>
{% endif %}
{% if blog_author.has_social_profiles %}
<div>
{% if blog_author.website %}
<a href="{{ blog_author.website }}" target="_blank" rel="noopener">
{% icon
name='link',
purpose='semantic',
style='SOLID',
title='Follow me on my website',
width='10'
%}
</a>
{% endif %}
{% if blog_author.facebook %}
<a href="{{ blog_author.facebook }}" target="_blank" rel="noopener">
{% icon
name='facebook-f',
purpose='semantic',
style='SOLID',
title='Follow me on Facebook',
width='10'
%}
</a>
{% endif %}
{% if blog_author.linkedin %}
<a href="{{ blog_author.linkedin }}" target="_blank" rel="noopener">
{% icon
name='linkedin-in',
purpose='semantic',
style='SOLID',
title='Follow me on LinkedIn',
width='10'
%}
</a>
{% endif %}
{% if blog_author.twitter %}
<a href="{{ blog_author.twitter }}" target="_blank" rel="noopener">
{% icon
name='twitter',
purpose='semantic',
style='SOLID',
title='Follow me on Twitter',
width='10'
%}
</a>
{% endif %}
</div>
{% endif %}
</div>
{% elif tag %}
{# End blog author listing #}

{# Blog tag listing #}
<div>
<h1>Posts about {{ page_meta.html_title|split(' | ')|last }}</h1>
</div>
{% else %}
{# End blog tag listing #}

{# Blog header #}
<div>
<h1>{{ group.public_title }}</h1>
<p>{{ group.description }}</p>
</div>
{% endif %}
{# End blog header #}

<div>

{# Blog listing section #}
<section>

{# Blog listing #}
{% for content in contents %}
<article>
{% if content.featured_image and group.use_featured_image_in_summary %}
<a href="{{ content.absolute_url }}">
<img src="{{ content.featured_image }}" alt="{{ content.featured_image_alt_text }}">
</a>
{% endif %}
<div>
<h2><a href="{{ content.absolute_url }}">{{ content.name }}</a></h2>
{% if content_group.show_summary_in_listing %}
{{ content.post_list_content|truncatehtml(100) }}
{% endif %}
</div>
</article>
{% endfor %}
{# End blog listing #}

</section>
{# End blog listing section #}

{# Blog pagination #}
{% if contents.total_page_count > 1 %}
<nav aria-label="Pagination" role="navigation">
{% set page_list = [-2, -1, 0, 1, 2] %}
{% if contents.total_page_count - current_page_num == 1 %}{% set offset = -1 %}
{% elif contents.total_page_count - current_page_num == 0 %}{% set offset = -2 %}
{% elif current_page_num == 2 %}{% set offset = 1 %}
{% elif current_page_num == 1 %}{% set offset = 2 %}
{% else %}{% set offset = 0 %}{% endif %}

<a class="blog-pagination__link blog-pagination__prev-link {{ 'blog-pagination__prev-link--disabled' if !last_page_num }}"{% if last_page_num %} href="{% if current_page_num == 2 %}{{ group.absolute_url }} {% else %}{{ blog_page_link(last_page_num) }}{% endif %}" rel="prev"{% else %} aria-disabled="true" disabled {% endif %} role="button" aria-label="Go to previous page">
Prev
</a>
{% for page in page_list %}
{% set this_page = current_page_num + page + offset %}
{% if this_page > 0 and this_page <= contents.total_page_count %}
<a class="blog-pagination__link blog-pagination__number-link {{ 'blog-pagination__link--active' if this_page == current_page_num }}" aria-label="Go to Page {{ this_page }}" {% if this_page == current_page_num %}aria-current="true"{% endif %} href="{% if this_page == 1 %}{{ group.absolute_url }}{% else %}{{ blog_page_link(this_page) }}{% endif %}">{{ this_page }}</a>
{% endif %}
{% endfor %}
<a class="blog-pagination__link blog-pagination__next-link {{ 'blog-pagination__next-link--disabled' if !next_page_num }}"{% if next_page_num %} href="{{ blog_page_link(current_page_num + 1) }}" rel="prev" {% else %} aria-disabled="true" disabled {% endif %} role="button" aria-label="Go to next page">
Next
</a>
</nav>
{% endif %}
{# End blog pagination #}

</div>

</main>
{{ standard_footer_includes }}
</body>
</html>
50 changes: 50 additions & 0 deletions packages/cms-cli/defaults/blog-post-template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
templateType: blog_post
isAvailableForNewContent: true
label: Blog post
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>{{ content.html_title }}</title>
<meta name="description" content="{{ content.meta_description }}" />
{{ standard_header_includes }}
</head>
<body>
<main>

{# Blog post #}
<article>
<h1>{{ content.name }}</h1>
<div>
<a href="{{ blog_author_url(group.id, content.blog_post_author.slug) }}" rel="author">
{{ content.blog_post_author.display_name }}
</a>
<time>
{{ content.publish_date_localized }}
</time>
</div>
<div>
{{ content.post_body }}
</div>
{% if content.tag_list %}
<div>
{% for tag in content.tag_list %}
<a href="{{ blog_tag_url(group.id, tag.slug) }}" rel="tag">{{ tag.name }}</a> {% if not loop.last %},{% endif %}
{% endfor %}
</div>
{% endif %}
</article>

{% if group.allow_comments %}
<div>
{% module 'blog_comments' path='@hubspot/blog_comments', label="Blog comments" %}
</div>
{% endif %}
{# End blog post #}

</main>
{{ standard_footer_includes }}
</body>
</html>
28 changes: 0 additions & 28 deletions packages/cms-cli/defaults/blog-template.html

This file was deleted.

3 changes: 2 additions & 1 deletion packages/cms-cli/lib/createTemplatePrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const TEMPLATE_TYPE_PROMPT = {
{ name: 'email', value: 'email-template' },
{ name: 'partial', value: 'partial' },
{ name: 'global partial', value: 'global-partial' },
{ name: 'blog', value: 'blog-template' },
{ name: 'blog listing', value: 'blog-listing-template' },
{ name: 'blog post', value: 'blog-post-template' },
{ name: 'search results', value: 'search-template' },
],
};
Expand Down