coyotte508 HF staff commited on
Commit
652223b
1 Parent(s): 9a79ad0

🔍 Fix title/description for SEO

Browse files
README.md CHANGED
@@ -18,4 +18,8 @@ pnpm install
18
 
19
  ```
20
  pnpm dev
21
- ```
 
 
 
 
 
18
 
19
  ```
20
  pnpm dev
21
+ ```
22
+
23
+ ## Original repo
24
+
25
+ https://github.com/coyotte508/bergere-enchantee
src/lib/utils/upperFirst.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ export function upperFirst(s: string): string {
2
+ return s[0].toLocaleUpperCase() + s.slice(1);
3
+ }
src/routes/+layout.svelte CHANGED
@@ -4,6 +4,7 @@
4
  import '@unocss/reset/normalize.css';
5
  import 'uno.css';
6
  import type { LayoutData } from './$types';
 
7
 
8
  $: path = $page.route?.id ?? '';
9
 
@@ -14,19 +15,22 @@
14
 
15
  let menuOpen = false;
16
  let date = new Date();
 
 
 
17
  </script>
18
 
19
  <svelte:head>
20
  <meta property="og:site_name" content="Bergère Enchantée" />
21
- {#if $page.data.title}
22
- <title>{$page.data.title}</title>
23
- <meta property="og:title" content={$page.data.title} />
24
- <meta property="twitter:title" content={$page.data.title} />
25
  {/if}
26
- {#if $page.data.description}
27
- <meta name="description" content={$page.data['search-engine-description']} />
28
- <meta property="og:description" content={$page.data['search-engine-description']} />
29
- <meta property="twitter:description" content={$page.data['search-engine-description']} />
30
  {/if}
31
  <meta property="og:type" content={$page.data.type || 'website'} />
32
  {#if shownPicture}
 
4
  import '@unocss/reset/normalize.css';
5
  import 'uno.css';
6
  import type { LayoutData } from './$types';
7
+ import { upperFirst } from '$lib/utils/upperFirst';
8
 
9
  $: path = $page.route?.id ?? '';
10
 
 
15
 
16
  let menuOpen = false;
17
  let date = new Date();
18
+
19
+ $: title = $page.data.title ?? data.pageData?.name ?? upperFirst(path?.split('/')?.[1]);
20
+ $: description = $page.data.description ?? data.pageData?.text['search-engine-description'];
21
  </script>
22
 
23
  <svelte:head>
24
  <meta property="og:site_name" content="Bergère Enchantée" />
25
+ {#if title}
26
+ <title>{title}</title>
27
+ <meta property="og:title" content={title} />
28
+ <meta property="twitter:title" content={title} />
29
  {/if}
30
+ {#if description}
31
+ <meta name="description" content={description} />
32
+ <meta property="og:description" content={description} />
33
+ <meta property="twitter:description" content={description} />
34
  {/if}
35
  <meta property="og:type" content={$page.data.type || 'website'} />
36
  {#if shownPicture}