Skip to content

Commit ea84d2f

Browse files
authored
fix: refactor metadata unique for each blog post (#79)
extended fixes for #75 + refactor + prettier
1 parent 06df34f commit ea84d2f

17 files changed

+246
-277
lines changed

elder.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ module.exports = {
3232
blog: {
3333
priority: 0.8,
3434
changfreq: 'daily',
35-
}
35+
},
3636
}, // set custom priority and change freq if not it falls back to default
3737
lastUpdate: {
3838
blog: async () => {
3939
return new Date(Date.now());
40-
}
40+
},
4141
}, // configurable last update for each route type.
4242
},
4343
'@elderjs/plugin-markdown': {

qa-testing/tests/simple.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ test('default true', async (t) => {
66
return true;
77
});
88
test('Check the home page title', async (t) => {
9-
await t.expect(HomePage.title).eql('Chris Phan - Hello World!');
9+
await t.expect(HomePage.title).eql('Chris Phan offers quality solutions that give you a competitive edge!');
1010
});

src/components/ContactForm.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
});
2424
};
2525
26-
/**
27-
* @todo add transitions to contact form
28-
* @body add fancy animations for ease-in as well as after submission
29-
*/
26+
/**
27+
* @todo add transitions to contact form
28+
* @body add fancy animations for ease-in as well as after submission
29+
*/
3030
</script>
3131

3232
<form form id="contact" name="contact" on:submit|preventDefault={handleSubmit} netlify netlify-honeypot="bot-field">

src/layouts/Layout.svelte

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import SideBar from '../components/SideBar.svelte';
44
import Header from '../components/Header.svelte';
55
import Footer from '../components/Footer.svelte';
6+
7+
const routeName = request.route.charAt(0).toUpperCase() + request.route.slice(1) || 'Hello World!';
68
</script>
79

810
<style global lang="postcss">
@@ -30,6 +32,13 @@
3032
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
3133
<meta name="language" content="English" />
3234
<meta name="author" content="[email protected]" />
35+
<meta name="title" content={data.title ?? settings.sitename + ' - ' + routeName} />
36+
{#if data.description}
37+
<meta name="description" content={data.description} />
38+
{/if}
39+
{#if data.keywords}
40+
<meta name="keywords" content={data.keywords} />
41+
{/if}
3342
<link rel="preconnect" href="https://fonts.gstatic.com" />
3443
<link
3544
rel="stylesheet"
@@ -38,6 +47,8 @@
3847
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap" rel="stylesheet" />
3948
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico" />
4049
<base href={settings.origin} />
50+
<link href="{settings.origin}{request.permalink}" rel="canonical" />
51+
<title>{data.title ?? settings.sitename + ' - ' + routeName}</title>
4152
</svelte:head>
4253

4354
<main class="flex flex-col w-full sm:h-screen z-1">

src/routes/blog/Blog.svelte

+7-9
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,6 @@
122122
/* purgecss end ignore */
123123
</style>
124124

125-
<svelte:head>
126-
<meta name="title" content="{settings.sitename} - {frontmatter.title}" />
127-
<meta name="description" content="{frontmatter.excerpt}" />
128-
<meta name="keywords" content="{frontmatter.keywords}" />
129-
<link href="{settings.origin}{request.permalink}" rel="canonical" />
130-
<title>{settings.sitename} - {frontmatter.title}</title>
131-
</svelte:head>
132-
133125
<a href="/" class="print:hidden">&LeftArrow; Home</a>
134126

135127
{#if html}
@@ -147,7 +139,13 @@
147139

148140
{#if frontmatter.cover}
149141
<div class="mx-5">
150-
<img class="object-cover {frontmatter.top?'object-top':''} {frontmatter.bottom?'object-bottom':''} w-screen max-h-96" src={frontmatter.cover} alt={frontmatter.caption} />
142+
<img
143+
class="object-cover {frontmatter.top ? 'object-top' : ''} {frontmatter.bottom
144+
? 'object-bottom'
145+
: ''} w-screen max-h-96"
146+
src={frontmatter.cover}
147+
alt={frontmatter.caption}
148+
/>
151149
</div>
152150
{/if}
153151

src/routes/blog/blog-a-day.md

+53-59
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,53 @@
1-
---
2-
topic: "Getting Started"
3-
title: "A blog a day. What does it take?"
4-
excerpt: "Achieving a blog a day is easy, and with the right tips, you'll be able to hit your target without breaking a sweat."
5-
keywords: "seo, ecommerce, marketing, blogging"
6-
date: "2022-01-22T01:58:52Z"
7-
cover: "https://images.unsplash.com/photo-1625296276703-3fbc924f07b5?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2670&q=80"
8-
top: yes
9-
caption: "Credit: @justin_morgan / unsplash.com"
10-
---
11-
12-
In today's competitive market, it takes something extra to stand out from the crowd. Some companies do this with flashy ads or clever marketing schemes. Others rely on their quality products or customer service. But one of the best ways to set yourself apart is by being a frequent blogger. A blog a day can show your clients that you're constantly working and keep you top-of-mind. Not sure where to start? This post will give you some ideas on how to create content that engages your audience and drives results.
13-
14-
## What are you passionate about and can write topics on without getting bored?
15-
16-
Do you find yourself browing interior design? Looking up recipes? There are blog posts for days (literally) on any topic that interests you. And if you're stuck for ideas, there are plenty of resources online to help get the creative juices flowing.
17-
18-
I get a lot of my inspiration from Discord servers, Facebook groups, or subreddits that I subscribe to. I'm a member of those groups because I enjoy reading what they have to offer, and I'm sure your audience will feel the same way about your blog.
19-
20-
Once you've found a topic you're interested in and are passionate about, it's time to start creating content. This doesn't mean you have to write a new blog post every day – there's other creative ways in keeping things interesting – you can also share articles, images, or videos that you think your audience will enjoy.
21-
22-
{{protip}}
23-
**Protip**: You're probably already doing this on Facebook and gaining a lot of likes. You're already making readers feel good from each post, that they're more than likely enjoy your next post. Simply convert that energy into a blog!
24-
{{/protip}}
25-
26-
27-
## Encourage your readers to share why they enjoy what you like.
28-
29-
This is a great way to start building a community around your blog and create loyalty among your readers. Don't be afraid to experiment with different formats and styles, either. Some people prefer shorter posts while others enjoy longer-form content. Find what works best for you and stick to it, but always be willing to try something new.
30-
31-
I prefer to keep blog articles between 600 and 1,000 words because this is the norm for professional news, particularly newspapers. I believe it's fairly effective in terms of getting exposure. Long-form blogs are another style I didn't discuss in this post, but it'll have to wait for another day.
32-
33-
{{protip}}
34-
**Protip**: Your audience are your friends. It's critical to be genuine and engaging. They will quickly abandon participation if you aren't genuine. Be yourself and pursue your dreams with enthusiasm!
35-
{{/protip}}
36-
37-
38-
## It all comes back to where it started. Use social media to share your material.
39-
40-
After you've established a few pieces, start promoting them on social media. Make sure to utilize relevant hashtags and @mentioning people who might be interested in your content. You may also post short excerpts from your writing on Twitter or Facebook, asking readers to go to your blog for the full story. This is an excellent method to attract new fans and followers.
41-
42-
I previously didn't use Facebook as much because I had nothing to share, however now that I have my blog, which will grow with more information, it will be one of the first places I post to. I usually use Instagram for items without context since it's faster.
43-
44-
Remember, your blog is a reflection of you, so write about what you love and are interested in. Be sure to add personality and excitement to your writing, and you'll start seeing results in no time.
45-
46-
{{protip}}
47-
**Protip**: You don't have to be perfect when writing for your blog; simply publish and accept constructive comments as they come.
48-
{{/protip}}
49-
50-
51-
## The Take Away
52-
53-
- Passion and interest are key to driving results.
54-
55-
- Build a community and experiment with content styles.
56-
57-
- Use social media to share your material and attract new readership.
58-
59-
- Have fun with your blog! It should be a reflection of you.
1+
---
2+
topic: 'Getting Started'
3+
title: 'A blog a day. What does it take?'
4+
excerpt: "Achieving a blog a day is easy, and with the right tips, you'll be able to hit your target without breaking a sweat."
5+
keywords: 'seo, ecommerce, marketing, blogging'
6+
date: '2022-01-22T01:58:52Z'
7+
cover: 'https://images.unsplash.com/photo-1625296276703-3fbc924f07b5?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2670&q=80'
8+
top: yes
9+
caption: 'Credit: @justin_morgan / unsplash.com'
10+
---
11+
12+
In today's competitive market, it takes something extra to stand out from the crowd. Some companies do this with flashy ads or clever marketing schemes. Others rely on their quality products or customer service. But one of the best ways to set yourself apart is by being a frequent blogger. A blog a day can show your clients that you're constantly working and keep you top-of-mind. Not sure where to start? This post will give you some ideas on how to create content that engages your audience and drives results.
13+
14+
## What are you passionate about and can write topics on without getting bored?
15+
16+
Do you find yourself browing interior design? Looking up recipes? There are blog posts for days (literally) on any topic that interests you. And if you're stuck for ideas, there are plenty of resources online to help get the creative juices flowing.
17+
18+
I get a lot of my inspiration from Discord servers, Facebook groups, or subreddits that I subscribe to. I'm a member of those groups because I enjoy reading what they have to offer, and I'm sure your audience will feel the same way about your blog.
19+
20+
Once you've found a topic you're interested in and are passionate about, it's time to start creating content. This doesn't mean you have to write a new blog post every day – there's other creative ways in keeping things interesting – you can also share articles, images, or videos that you think your audience will enjoy.
21+
22+
{{protip}}
23+
**Protip**: You're probably already doing this on Facebook and gaining a lot of likes. You're already making readers feel good from each post, that they're more than likely enjoy your next post. Simply convert that energy into a blog!
24+
{{/protip}}
25+
26+
## Encourage your readers to share why they enjoy what you like.
27+
28+
This is a great way to start building a community around your blog and create loyalty among your readers. Don't be afraid to experiment with different formats and styles, either. Some people prefer shorter posts while others enjoy longer-form content. Find what works best for you and stick to it, but always be willing to try something new.
29+
30+
I prefer to keep blog articles between 600 and 1,000 words because this is the norm for professional news, particularly newspapers. I believe it's fairly effective in terms of getting exposure. Long-form blogs are another style I didn't discuss in this post, but it'll have to wait for another day.
31+
32+
{{protip}}
33+
**Protip**: Your audience are your friends. It's critical to be genuine and engaging. They will quickly abandon participation if you aren't genuine. Be yourself and pursue your dreams with enthusiasm!
34+
{{/protip}}
35+
36+
## It all comes back to where it started. Use social media to share your material.
37+
38+
After you've established a few pieces, start promoting them on social media. Make sure to utilize relevant hashtags and @mentioning people who might be interested in your content. You may also post short excerpts from your writing on Twitter or Facebook, asking readers to go to your blog for the full story. This is an excellent method to attract new fans and followers.
39+
40+
I previously didn't use Facebook as much because I had nothing to share, however now that I have my blog, which will grow with more information, it will be one of the first places I post to. I usually use Instagram for items without context since it's faster.
41+
42+
Remember, your blog is a reflection of you, so write about what you love and are interested in. Be sure to add personality and excitement to your writing, and you'll start seeing results in no time.
43+
44+
{{protip}}
45+
**Protip**: You don't have to be perfect when writing for your blog; simply publish and accept constructive comments as they come.
46+
{{/protip}}
47+
48+
## The Take Away
49+
50+
- Passion and interest are key to driving results.
51+
- Build a community and experiment with content styles.
52+
- Use social media to share your material and attract new readership.
53+
- Have fun with your blog! It should be a reflection of you.

0 commit comments

Comments
 (0)