Giter Site home page Giter Site logo

oekazuma / svelte-meta-tags Goto Github PK

View Code? Open in Web Editor NEW
506.0 4.0 20.0 3.81 MB

Svelte Meta Tags provides components designed to help you manage SEO for Svelte projects.

License: MIT License

JavaScript 1.54% Svelte 37.01% HTML 1.01% TypeScript 60.43%
svelte sveltekit seo metadata metatags

svelte-meta-tags's Introduction

svelte-meta-tags

CI download npm MIT

Svelte Meta Tags provides components designed to help you manage SEO for Svelte projects.

Demo

Note: If you are migrating from v2.x to v3.x, Please Read Migration Guide

Table of Contents

πŸ“¦ Installing

npm install -D svelte-meta-tags

or

yarn add -D svelte-meta-tags

or

pnpm add -D svelte-meta-tags

πŸš€ Usage

Example with just title and description:

<script>
  import { MetaTags } from 'svelte-meta-tags';
</script>

<MetaTags title="Example Title" description="Example Description." />

Typical page example:

<script>
  import { MetaTags } from 'svelte-meta-tags';
</script>

<MetaTags
  title="Using More of Config"
  titleTemplate="%s | Svelte Meta Tags"
  description="This example uses more of the available config options."
  canonical="https://www.canonical.ie/"
  openGraph={{
    url: 'https://www.url.ie/a',
    title: 'Open Graph Title',
    description: 'Open Graph Description',
    images: [
      {
        url: 'https://www.example.ie/og-image-01.jpg',
        width: 800,
        height: 600,
        alt: 'Og Image Alt'
      },
      {
        url: 'https://www.example.ie/og-image-02.jpg',
        width: 900,
        height: 800,
        alt: 'Og Image Alt Second'
      },
      { url: 'https://www.example.ie/og-image-03.jpg' },
      { url: 'https://www.example.ie/og-image-04.jpg' }
    ],
    siteName: 'SiteName'
  }}
  twitter={{
    handle: '@handle',
    site: '@site',
    cardType: 'summary_large_image',
    title: 'Using More of Config',
    description: 'This example uses more of the available config options.',
    image: 'https://www.example.ie/twitter-image.jpg',
    imageAlt: 'Twitter image alt'
  }}
  facebook={{
    appId: '1234567890'
  }}
/>

Overwriting default values with a child page:

Example

+layout.svelte

<script>
  import { MetaTags } from 'svelte-meta-tags';
  import { page } from '$app/stores';
  import extend from 'just-extend'; // Please provide functions that allow deep merging of objects, such as lodash.merge, deepmerge, just-extend.

  export let data;

  $: metaTags = extend(true, {}, data.baseMetaTags, $page.data.pageMetaTags);
</script>

<MetaTags {...metaTags} />

<slot />

+layout.ts

import type { MetaTagsProps } from 'svelte-meta-tags';

export const load = ({ url }) => {
  const baseMetaTags = Object.freeze({
    title: 'Default',
    titleTemplate: '%s | Svelte Meta Tags',
    description: 'Svelte Meta Tags is a Svelte component for managing meta tags and SEO in your Svelte applications.',
    canonical: new URL(url.pathname, url.origin).href,
    openGraph: {
      type: 'website',
      url: new URL(url.pathname, url.origin).href,
      locale: 'en_IE',
      title: 'Open Graph Title',
      description: 'Open Graph Description',
      siteName: 'SiteName',
      images: [
        {
          url: 'https://www.example.ie/og-image.jpg',
          alt: 'Og Image Alt',
          width: 800,
          height: 600,
          secureUrl: 'https://www.example.ie/og-image.jpg',
          type: 'image/jpeg'
        }
      ]
    }
  }) satisfies MetaTagsProps;

  return {
    baseMetaTags
  };
};

+page.ts

import type { MetaTagsProps } from 'svelte-meta-tags';

export const load = () => {
  const pageMetaTags = Object.freeze({
    title: 'TOP',
    description: 'Description TOP',
    openGraph: {
      title: 'Open Graph Title TOP',
      description: 'Open Graph Description TOP'
    }
  }) satisfies MetaTagsProps;

  return {
    pageMetaTags
  };
};

MetaTags Properties

Property Type Description
title string Sets the meta title of the page
titleTemplate string Allows you to set the default title template that will be added to your title More Info
robots string or boolean (default index,follow) Sets the meta robots of the page ⚠ You can disable it completely by setting it to false, but use it with caution as there is a risk that the page will not be indexed⚠
additionRobotsProps Object Set the additional meta information for the X-Robots-Tag More Info
description string Sets the meta description of the page
canonical string Make the page canonical URL
keywords array Sets the meta keywords of the page
mobileAlternate.media string Set the screen size from which the mobile site will be served
mobileAlternate.href string Set the alternate URL for the mobile page
languageAlternates array Set the language of the alternate urls. Expects array of objects with the shape: { hrefLang: string, href: string }
additionalMetaTags array Allows you to add a meta tag that is not documented here More Info
additionalLinkTags array Allows you to add a link tag that is not documented here More Info
twitter.cardType string The card type, which will be one of summary, summary_large_image, app, or player
twitter.site string @username for the website used in the card footer
twitter.handle string @username for the creator of the content (output as twitter:creator)
twitter.title string The concise title for the related content
twitter.description string The description that concisely summarizes the content in a manner suitable for presentation within a Tweet. You should not reuse the title as the description or use this field to describe the general services provided by the website
twitter.image string The URL to a unique image that represents the content of the page. You should not use a generic image such as your site logo, author photo, or other image that spans multiple pages. Images for this card support a 1:1 aspect ratio with a minimum size of 144x144 pixels or a maximum size of 4096x4096 pixels. Images must be less than 5MB in size. The image will be cropped to a square on all platforms. JPG, PNG, WEBP, and GIF formats are supported. Only the first frame of an animated GIF is used. SVG is not supported
twitter.imageAlt string The textual description of the image that conveys the essence of the image to visually impaired users. Maximum 420 characters
facebook.appId string For Facebook Insights, you will need to add a Facebook app ID to your page in order to use it
openGraph.url string The canonical URL of your object, which will be used as its permanent ID in the graph
openGraph.type string The type of your object. Depending on the type you specify, other properties may also be required More Info
openGraph.title string The open graph title, this can be different from your meta title
openGraph.description string The open graph description, which may be different from your meta description
openGraph.images array An array of images to use as previews. If multiple are provided, you can choose one when sharing See Examples
openGraph.videos array An array of videos (object)
openGraph.audio array An array of audio(object)
openGraph.locale string The locale in which the open graph tags are highlighted
openGraph.siteName string If your item is part of a larger website, the name that should be displayed for the entire site
openGraph.profile.firstName string Person's first name
openGraph.profile.lastName string Person's last name
openGraph.profile.username string Person's username
openGraph.profile.gender string Person's gender
openGraph.book.authors string[] Author of the article See Examples
openGraph.book.isbn string The ISBN
openGraph.book.releaseDate datetime The date the book was released
openGraph.book.tags string[] Tag words related to this book
openGraph.article.publishedTime datetime When the article was first published See Examples
openGraph.article.modifiedTime datetime When the item was last modified
openGraph.article.expirationTime datetime When the article is out of date after
openGraph.article.authors string[] Author of the article
openGraph.article.section string A high-level section name. E.g. Technology
openGraph.article.tags string[] Tag words associated with this article

Title Template

Replace %s with your title string.

title = 'This is my title'
titleTemplate = 'Svelte Meta Tags | %s'
// outputs: Svelte Meta Tags | This is my title
title = 'This is my title'
titleTemplate = '%s | Svelte Meta Tags'
// outputs: This is my title | Svelte Meta Tags

Twitter

twitter={{
  handle: '@handle',
  site: '@site',
  cardType: 'summary_large_image',
  title: 'Twitter',
  description: 'Twitter',
  image: 'https://www.example.ie/twitter-image.jpg',
  imageAlt: 'Twitter image alt'
}}

See out the Twitter documentation for more information.

Facebook

facebook={{
  appId: '1234567890',
}}

Add this to your SEO config to include the fb:app_id meta if you need to enable Facebook Insights for your site. Information on this can be found in Facebook's documentation.

additionalRobotsProps

In addition to index, follow the robots meta tag accepts more properties to archive a more accurate crawling and serve better snippets for SEO bots that crawl your page.

Example:

<script>
  import { MetaTags } from 'svelte-meta-tags';
</script>

<MetaTags
  additionalRobotsProps={{
    noarchive: true,
    nosnippet: true,
    maxSnippet: -1,
    maxImagePreview: 'none',
    maxVideoPreview: -1,
    notranslate: true,
    noimageindex: true,
    unavailableAfter: '25 Jun 2010 15:00:00 PST'
  }}
/>

Available properties

Property Type Description
noarchive boolean Do not display a cached link in search results
nosnippet boolean Do not show a text snippet or video preview in the search results for this page
maxSnippet number Use a maximum of [number] characters as the text snippet for this search result Read more
maxImagePreview 'none','standard','large' Set the maximum size of an image preview for this page in a search result
maxVideoPreview number Use a maximum of [number] seconds as a video snippet for videos on this page in search results Read more
notranslate boolean Do not offer translation of this page in search results
noimageindex boolean Do not index images on this page
unavailableAfter string Do not show this page in search results after the specified date/time. The date/time must be in a widely accepted format, including but not limited to RFC 822, RFC 850, and ISO 8601

For more information on the X-Robots-Tag visit Google Search Central - Control Crawling and Indexing

Alternate

This link relationship is used to indicate a relationship between a desktop and mobile website to search engines.

Example:

mobileAlternate={{
  media: 'only screen and (max-width: 640px)',
  href: 'https://m.canonical.ie'
}}
languageAlternates={[
  {
    hrefLang: 'de-AT',
    href: 'https://www.canonical.ie/de'
  }
]}

Additional Meta Tags

This allows you to add any other meta tags that are not required by the config.

content is required. Then either name, property or httpEquiv. (only one of each)

Example:

additionalMetaTags={[
  {
    property: 'dc:creator',
    content: 'Jane Doe'
  },
  {
    name: 'application-name',
    content: 'Svelte-Meta-Tags'
  },
  {
    httpEquiv: 'x-ua-compatible',
    content: 'IE=edge; chrome=1'
  }
]}

Invalid Examples:

These are invalid because they contain more than one of name, property, and httpEquiv in the same entry.

additionalMetaTags={[
  {
    property: 'dc:creator',
    name: 'dc:creator',
    content: 'Jane Doe'
  },
  {
    property: 'application-name',
    httpEquiv: 'application-name',
    content: 'Svelte-Meta-Tags'
  }
]}

One thing to note on this is that it currently only supports unique tags. This means it will only render one tag per unique name / property / httpEquiv. The last one defined will be rendered.

Example:

If you pass:

additionalMetaTags={[
  {
    property: 'dc:creator',
    content: 'John Doe'
  },
  {
    property: 'dc:creator',
    content: 'Jane Doe'
  }
]}

it will result in this being rendered:

<meta property="dc:creator" content="Jane Doe" />,

Additional Link Tags

This allows you to add any other link tags that are not covered in the config.

rel and href is required.

Example:

additionalLinkTags={[
  {
    rel: 'icon',
    href: 'https://www.test.ie/favicon.ico'
  },
  {
    rel: 'apple-touch-icon',
    href: 'https://www.test.ie/touch-icon-ipad.jpg',
    sizes: '76x76'
  },
  {
    rel: 'manifest',
    href: 'https://www.test.ie/manifest.json'
  }
]}

it will result in this being rendered:

<link rel="icon" href="https://www.test.ie/favicon.ico" />
<link rel="apple-touch-icon" href="https://www.test.ie/touch-icon-ipad.jpg" sizes="76x76" />
<link rel="manifest" href="https://www.test.ie/manifest.json" />

Open Graph

The full specification can be found at http://ogp.me/.

Svelte Meta Tags currently supports:

Open Graph Examples

Basic

<script>
  import { MetaTags } from 'svelte-meta-tags';
</script>

<MetaTags
  openGraph={{
    type: 'website',
    url: 'https://www.example.com/page',
    title: 'Open Graph Title',
    description: 'Open Graph Description',
    images: [
      {
        url: 'https://www.example.ie/og-image.jpg',
        width: 800,
        height: 600,
        alt: 'Og Image Alt'
      },
      {
        url: 'https://www.example.ie/og-image-2.jpg',
        width: 800,
        height: 600,
        alt: 'Og Image Alt 2'
      }
    ]
  }}
/>

Video

Full info on http://ogp.me/

<script>
  import { MetaTags } from 'svelte-meta-tags';
</script>

<MetaTags
  title="Video Page Title"
  description="Description of video page"
  openGraph={{
    title: 'Open Graph Video Title',
    description: 'Description of open graph video',
    url: 'https://www.example.com/videos/video-title',
    type: 'video.movie',
    video: {
      actors: [
        {
          profile: 'https://www.example.com/actors/@firstnameA-lastnameA',
          role: 'Protagonist'
        },
        {
          profile: 'https://www.example.com/actors/@firstnameB-lastnameB',
          role: 'Antagonist'
        }
      ],
      directors: [
        'https://www.example.com/directors/@firstnameA-lastnameA',
        'https://www.example.com/directors/@firstnameB-lastnameB'
      ],
      writers: [
        'https://www.example.com/writers/@firstnameA-lastnameA',
        'https://www.example.com/writers/@firstnameB-lastnameB'
      ],
      duration: 680000,
      releaseDate: '2022-12-21T22:04:11Z',
      tags: ['Tag A', 'Tag B', 'Tag C']
    },
    siteName: 'SiteName'
  }}
/>

Article

<script>
  import { MetaTags } from 'svelte-meta-tags';
</script>

<MetaTags
  openGraph={{
    title: 'Open Graph Article Title',
    description: 'Description of open graph article',
    url: 'https://www.example.com/articles/article-title',
    type: 'article',
    article: {
      publishedTime: '2017-06-21T23:04:13Z',
      modifiedTime: '2018-01-21T18:04:43Z',
      expirationTime: '2022-12-21T22:04:11Z',
      section: 'Section II',
      authors: [
        'https://www.example.com/authors/@firstnameA-lastnameA',
        'https://www.example.com/authors/@firstnameB-lastnameB'
      ],
      tags: ['Tag A', 'Tag B', 'Tag C']
    },
    images: [
      {
        url: 'https://www.test.ie/images/cover.jpg',
        width: 850,
        height: 650,
        alt: 'Photo of text'
      }
    ]
  }}
/>

Book

<script>
  import { MetaTags } from 'svelte-meta-tags';
</script>

<MetaTags
  openGraph={{
    title: 'Open Graph Book Title',
    description: 'Description of open graph book',
    url: 'https://www.example.com/books/book-title',
    type: 'book',
    book: {
      releaseDate: '2018-09-17T11:08:13Z',
      isbn: '978-3-16-148410-0',
      authors: [
        'https://www.example.com/authors/@firstnameA-lastnameA',
        'https://www.example.com/authors/@firstnameB-lastnameB'
      ],
      tags: ['Tag A', 'Tag B', 'Tag C']
    },
    images: [
      {
        url: 'https://www.test.ie/images/book.jpg',
        width: 850,
        height: 650,
        alt: 'Cover of the book'
      }
    ]
  }}
/>

Profile

<script>
  import { MetaTags } from 'svelte-meta-tags';
</script>

<MetaTags
  openGraph={{
    title: 'Open Graph Profile Title',
    description: 'Description of open graph profile',
    url: 'https://www.example.com/@firstlast123',
    type: 'profile',
    profile: {
      firstName: 'First',
      lastName: 'Last',
      username: 'firstlast123',
      gender: 'female'
    },
    images: [
      {
        url: 'https://www.test.ie/images/profile.jpg',
        width: 850,
        height: 650,
        alt: 'Profile Photo'
      }
    ]
  }}
/>

JSON-LD

JSON-LD allows for more customized and richer display, such as in search results.

To discover all the different content types that JSON-LD offers, go to: https://developers.google.com/search/docs/guides/search-gallery

Tips: If you want to handle multiple JSON-LDs on one page, pass an array to the schema.

Using schema-dts

This plugin uses schema-dts, so it provides other types than the examples below.

JSON-LD Properties

Property Type Description
output string (default head) Specifies whether to output json-ld in <head> or <body>. Possible values are either head or body
schema Object Data in ld+json format See Examples

JSON-LD Examples

Article

<script>
  import { JsonLd } from 'svelte-meta-tags';
</script>

<JsonLd
  schema={{
    '@type': 'Article',
    mainEntityOfPage: {
      '@type': 'WebPage',
      '@id': 'https://example.com/article'
    },
    headline: 'Article headline',
    image: [
      'https://example.com/photos/1x1/photo.jpg',
      'https://example.com/photos/4x3/photo.jpg',
      'https://example.com/photos/16x9/photo.jpg'
    ],
    datePublished: '2015-02-05T08:00:00+08:00',
    dateModified: '2015-02-05T09:20:00+08:00',
    author: {
      '@type': 'Person',
      name: 'John Doe'
    },
    publisher: {
      '@type': 'Organization',
      name: 'Google',
      logo: {
        '@type': 'ImageObject',
        url: 'https://example.com/logo.jpg'
      }
    }
  }}
/>

Breadcrumb

<script>
  import { JsonLd } from 'svelte-meta-tags';
</script>

<JsonLd
  schema={{
    '@type': 'BreadcrumbList',
    itemListElement: [
      {
        '@type': 'ListItem',
        position: 1,
        name: 'Books',
        item: 'https://example.com/books'
      },
      {
        '@type': 'ListItem',
        position: 2,
        name: 'Science Fiction',
        item: 'https://example.com/books/sciencefiction'
      },
      {
        '@type': 'ListItem',
        position: 3,
        name: 'Award Winners'
      }
    ]
  }}
/>

Product

<script>
  import { JsonLd } from 'svelte-meta-tags';
</script>

<JsonLd
  schema={{
    '@type': 'Product',
    name: 'Executive Anvil',
    image: [
      'https://example.com/photos/1x1/photo.jpg',
      'https://example.com/photos/4x3/photo.jpg',
      'https://example.com/photos/16x9/photo.jpg'
    ],
    description:
      "Sleeker than ACME's Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.",
    sku: '0446310786',
    mpn: '925872',
    brand: {
      '@type': 'Brand',
      name: 'ACME'
    },
    review: {
      '@type': 'Review',
      reviewRating: {
        '@type': 'Rating',
        ratingValue: '4',
        bestRating: '5'
      },
      author: {
        '@type': 'Person',
        name: 'Fred Benson'
      }
    },
    aggregateRating: {
      '@type': 'AggregateRating',
      ratingValue: '4.4',
      reviewCount: '89'
    },
    offers: {
      '@type': 'Offer',
      url: 'https://example.com/anvil',
      priceCurrency: 'USD',
      price: '119.99',
      priceValidUntil: '2020-11-20',
      itemCondition: 'https://schema.org/UsedCondition',
      availability: 'https://schema.org/InStock'
    }
  }}
/>

Course

<script>
  import { JsonLd } from 'svelte-meta-tags';
</script>

<JsonLd
  schema={{
    '@type': 'Course',
    name: 'Introduction to Computer Science and Programming',
    description: 'Introductory CS course laying out the basics.',
    provider: {
      '@type': 'Organization',
      name: 'University of Technology - Eureka',
      sameAs: 'http://www.ut-eureka.edu'
    }
  }}
/>

DataSet

<script>
  import { JsonLd } from 'svelte-meta-tags';
</script>

<JsonLd
  schema={{
    '@type': 'Dataset',
    name: 'name of the dataset',
    description: 'The description needs to be at least 50 characters long',
    license: 'https//www.example.com'
  }}
/>

FAQ

<script>
  import { JsonLd } from 'svelte-meta-tags';
</script>

<JsonLd
  schema={{
    '@type': 'FAQPage',
    mainEntity: [
      {
        '@type': 'Question',
        name: 'How long is the delivery time?',
        acceptedAnswer: {
          '@type': 'Answer',
          text: '3-5 business days.'
        }
      },
      {
        '@type': 'Question',
        name: 'Where can I find information about product recalls?',
        acceptedAnswer: {
          '@type': 'Answer',
          text: 'Read more on under information.'
        }
      }
    ]
  }}
/>

JSON-LD Multiple Examples

<script>
  import { JsonLd } from 'svelte-meta-tags';
</script>

<JsonLd
  schema={[
    {
      '@type': 'BreadcrumbList',
      itemListElement: [
        {
          '@type': 'ListItem',
          position: 1,
          name: 'Books',
          item: 'https://example.com/books'
        },
        {
          '@type': 'ListItem',
          position: 2,
          name: 'Science Fiction',
          item: 'https://example.com/books/sciencefiction'
        },
        {
          '@type': 'ListItem',
          position: 3,
          name: 'Award Winners'
        }
      ]
    },
    {
      '@type': 'NewsArticle',
      mainEntityOfPage: {
        '@type': 'WebPage',
        '@id': 'https://google.com/article'
      },
      headline: 'Article headline',
      image: [
        'https://example.com/photos/1x1/photo.jpg',
        'https://example.com/photos/4x3/photo.jpg',
        'https://example.com/photos/16x9/photo.jpg'
      ],
      datePublished: '2015-02-05T08:00:00+08:00',
      dateModified: '2015-02-05T09:20:00+08:00',
      author: {
        '@type': 'Person',
        name: 'John Doe'
      },
      publisher: {
        '@type': 'Organization',
        name: 'Google',
        logo: {
          '@type': 'ImageObject',
          url: 'https://google.com/logo.jpg'
        }
      }
    }
  ]}
/>

Types

The following types can be imported from svelte-meta-tags

MetaTagsProps

interface MetaTagsProps {
  title?: string;
  titleTemplate?: string;
  robots?: string | boolean;
  additionalRobotsProps?: AdditionalRobotsProps;
  description?: string;
  canonical?: string;
  mobileAlternate?: MobileAlternate;
  languageAlternates?: ReadonlyArray<LanguageAlternate>;
  twitter?: Twitter;
  facebook?: Facebook;
  openGraph?: OpenGraph;
  additionalMetaTags?: ReadonlyArray<MetaTag>;
  additionalLinkTags?: ReadonlyArray<LinkTag>;
}

JsonLdProps

interface JsonLdProps {
  output?: 'head' | 'body';
  schema?: Thing | WithContext<Thing> | Thing[] | WithContext<Thing>[];
}

AdditionalRobotsProps

interface AdditionalRobotsProps {
  nosnippet?: boolean;
  maxSnippet?: number;
  maxImagePreview?: 'none' | 'standard' | 'large';
  maxVideoPreview?: number;
  noarchive?: boolean;
  unavailableAfter?: string;
  noimageindex?: boolean;
  notranslate?: boolean;
}

MobileAlternate

interface MobileAlternate {
  media: string;
  href: string;
}

LanguageAlternate

interface LanguageAlternate {
  hrefLang: string;
  href: string;
}

Twitter

interface Twitter {
  cardType?: 'summary' | 'summary_large_image' | 'app' | 'player';
  site?: string;
  handle?: string;
  title?: string;
  description?: string;
  image?: string;
  imageAlt?: string;
}

Facebook

interface Facebook {
  appId?: string;
}

OpenGraph

interface OpenGraph {
  url?: string;
  type?: string;
  title?: string;
  description?: string;
  images?: ReadonlyArray<OpenGraphImage>;
  videos?: ReadonlyArray<OpenGraphVideos>;
  audio?: ReadonlyArray<OpenGraphAudio>;
  locale?: string;
  siteName?: string;
  profile?: OpenGraphProfile;
  book?: OpenGraphBook;
  article?: OpenGraphArticle;
  video?: OpenGraphVideo;
}

MetaTag

type MetaTag = HTML5MetaTag | RDFaMetaTag | HTTPEquivMetaTag;

LinkTag

interface LinkTag {
  rel: string;
  href: string;
  hrefLang?: string;
  media?: string;
  sizes?: string;
  type?: string;
  color?: string;
  as?: string;
  crossOrigin?: string;
  referrerPolicy?: string;
}

Additional types

The following are referenced by the public types documented above, but cannot be imported directly

OpenGraphImage

interface OpenGraphImage {
  url: string;
  secureUrl?: string;
  type?: string;
  width?: number;
  height?: number;
  alt?: string;
}

OpenGraphVideos

interface OpenGraphVideos {
  url: string;
  secureUrl?: string;
  type?: string;
  width?: number;
  height?: number;
}

OpenGraphAudio

interface OpenGraphAudio {
  url: string;
  secureUrl?: string;
  type?: string;
}

OpenGraphProfile

interface OpenGraphProfile {
  firstName?: string;
  lastName?: string;
  username?: string;
  gender?: string;
}

OpenGraphBook

interface OpenGraphBook {
  authors?: ReadonlyArray<string>;
  isbn?: string;
  releaseDate?: string;
  tags?: ReadonlyArray<string>;
}

OpenGraphArticle

interface OpenGraphArticle {
  publishedTime?: string;
  modifiedTime?: string;
  expirationTime?: string;
  authors?: ReadonlyArray<string>;
  section?: string;
  tags?: ReadonlyArray<string>;
}

OpenGraphVideo

interface OpenGraphVideo {
  actors?: ReadonlyArray<OpenGraphVideoActors>;
  directors?: ReadonlyArray<string>;
  writers?: ReadonlyArray<string>;
  duration?: number;
  releaseDate?: string;
  tags?: ReadonlyArray<string>;
  series?: string;
}

OpenGraphVideoActors

interface OpenGraphVideoActors {
  profile: string;
  role?: string;
}

BaseMetaTag

interface BaseMetaTag {
  content: string;
}

HTML5MetaTag

interface HTML5MetaTag extends BaseMetaTag {
  name: string;
  property?: undefined;
  httpEquiv?: undefined;
}

RDFaMetaTag

interface RDFaMetaTag extends BaseMetaTag {
  property: string;
  name?: undefined;
  httpEquiv?: undefined;
}

HTTPEquivMetaTag

interface HTTPEquivMetaTag extends BaseMetaTag {
  httpEquiv: 'content-security-policy' | 'content-type' | 'default-style' | 'x-ua-compatible' | 'refresh';
  name?: undefined;
  property?: undefined;
}

License

MIT

svelte-meta-tags's People

Contributors

danisal avatar github-actions[bot] avatar jack-weilage avatar nekochan0122 avatar oekazuma avatar rallisf1 avatar renovate-bot avatar renovate[bot] avatar ricardobeat avatar semantic-release-bot avatar tristanbrotherton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

svelte-meta-tags's Issues

Migration to monorepo

Change the repository to monorepo so that we can test each of Svelte v3 and v4.
We are thinking of making the documentation a site in the future, so we decided to go with monorepo for this purpose.

Add support for Telegram Channel

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
A telegram meta tag.

Describe alternatives you've considered
Adding it myself to the head on ever page.

Additional context
Number one most downloaded app last year.

<meta name="telegram:channel" content="@channel_name">

Schema Can be an Array

A JSON-LD schema can be an array of items. This should be accepted:

https://stackoverflow.com/a/32954313/271450
https://stackoverflow.com/questions/48294593/how-do-you-combine-several-json-ld-markups/48295719#48295719

If it is an array, the @context could be added to each item.


Here is one option:

	// create schema with context
	function createSchema(schema: any) {
		// add context
		const addContext = (c: any) => ({ '@context': 'http://schema.org', ...c });

		// handle object
		if (!Array.isArray(schema)) {
			return addContext(schema);
		}

		// handle array
		schema = schema.map((v) => addContext(v));
		return schema.length === 1 ? schema[0] : schema;
	}

	$: json = `${'<scri' + 'pt type="application/ld+json">'}${JSON.stringify(createSchema(schema))}${
		'</scri' + 'pt>'
	}`;

J

Dependency or devDependency

Thanks for making SEO easier with Svelte. I saw this package is referenced in the Svelte docs here and I'm looking forward do dropping some schema data into my app. Perhaps this is a broader discussion topic but I thought I'd raise it here since you're linked to from the official docs. What's your stance on including this as a devDependency as opposed to a dependency? The way I understand it when I compile my svelte app I don't need this package anymore so, therefore, I assume it shuld be a devDependency. Am I thinking about this incorrectly?

[Question] not showing when I paste url to FB

I'm sorry asking a question here.

I created Facebook app and app-Id.

I used https://developers.facebook.com/tools/debug/ and all good, showing an image, fb:app_id , og:url, og:type, og:title, og:image, og:description, og:site_name, etc.

However when I paste a link on a Facebook in "What's on your mind?', it shows nothing.
What could be done to fix it?
I appreciate if you have any ideas.

Thank you in advance.

Unknown file extension .svelte after upgrading to Svelte 3.52

Describe the bug

After upgrading to Svelte 3.52.0, svelte-meta-tags cannot be used anymore. I've seen 2 different problems:

Unknown file extension ".svelte" for /route-to-project/web/node_modules/svelte-meta-tags/MetaTags.svelte

or

Cannot find module 'svelte-meta-tags' imported from '/route-to-project/web/src/lib/components/ComponentName.svelte'

After looking for it in the Internet, I've seen several reports on how to fix it (like this one).

I've seen this commit of you that already was adding the needed properties, but if I look at package.json in v2.6.3 of this plugin, I must change this:

  },
  "svelte": "./index.js",
}

into this:

  },
  "svelte": "./index.js",
  "main": "./index.js"
}

Then it starts working fine again.

So I don't know who builds package.json, but it seems it's forgetting to add the "main" line?

Duplicative JSON-LD Output

Describe the bug
Writing JSON-LD to the page results in duplicative output.

Reproduction

  1. git clone https://github.com/vhscom/repro-duplicative-jsonld-meta.git to copy minimal test case
  2. pnpm i && pnpm dev -- --open to open the error page
  3. Observe the following in dev and production builds:
    <!-- HTML_TAG_START -->
    <script type="application/ld+json">{ ... }</script>
    <!-- HTML_TAG_END -->
    <script type="application/ld+json">{ ... }</script>

Additional context
Issue reproduced by initializing a fresh SvelteKit project and copy/pasting README example for JSON-LD. See the pnpm-lock.yaml for the exact resource versions used to reproduce, copied below for convenience:

Aside
JSON-LD gets moved to page head whereas I'd expect it to output where the JsonLd tag is placed.

Internalization support

Is your feature request related to a problem? Please describe.
When using any type of internalization plugin the meta fields don't update on language change.

Describe the solution you'd like
You should use a store for props object in order to auto refresh the meta-tags with zero-configuration

Describe alternatives you've considered
My workaround for typesafe-i18n is:

import { MetaTags, MetaTagsProps } from 'svelte-meta-tags';
import LL, { locale } from '../i18n/i18n-svelte';
import { locales } from "../i18n/i18n-util";
import { afterUpdate } from 'svelte';

let metaTags: MetaTagsProps = {
	title: '',
	description: '',
	languageAlternates: []
}

afterUpdate(() => {
	[, , ...pageParts] = $page.path.split("/");
	updateMetaLang();
});

function updateMetaLang(){
	let altLangs = [];
	locales.forEach((lang, _) => {
		if(lang != $locale){
			altLangs.push({
				hrefLang: lang,
				href: `https://${$page.host}/${lang}${$page.path.slice(3)}` // it's ugly but it works
			})
		}
	});
	metaTags.languageAlternates = altLangs;
	metaTags.title = LL.site_name();
	metaTags.description = LL.site_description();
}

Export all types not only MetaTagsProps and JsonLdProps

Related to #22, but instead of export just MetaTagsProps and JsonLdProps, can we get all types? So i can make this:

import type { Twitter, Facebook } ...

const twitterData: Twitter = {}
const fbData: Facebook = {}
<MetaTags
  title="Using More of Config"
  description="This example uses more of the available config options."
  canonical="https://www.canonical.ie/"
  openGraph={openGraphData}
  twitter={twitterData}
  facebook={facebookData}
/>

og:type is not working

Describe the bug
A clear and concise description of what the bug is.

in +layout.svelte

<MetaTags
    titleTemplate="%s - App"
    openGraph={{
        type: "website",
        url: href,
    }}
    canonical={href}
    {...$page.data.metaTagsChild}
/>

all tags are working except openGraph.type

Twitter:title and description

Hi, I want to use this library in my portfolio project and I really loved the json format in which it is structured. My request is in regards of twitter:title and twitter:description. I found out that there's not any tag here. Although, I know I can use additionalMetaTags to add it but I'd love to see this both tags as per below

twitter={{
    handle: '@handle',
    site: '@site',
    cardType: 'summary_large_image', 
    title: 'This is title',
    description: 'This is description'
  }}

[FEAT] - support/extend `robots` via `robotsProps.robots`

I am looking to support a variety of use cases. However, we are concerned that adding a robots property would complicate the properties that affect the robots element.

I'm still struggling with what to do, but I'm wondering if integrating the robots feature with the robotsProps feature might be a solution?

Originally posted by @oekazuma in #750 (comment)

v3

Here is a summary of what needs to be done for v3.
Please give me any requests you would like to see added to v3.

  • πŸ”₯ Remove the googlebot tag. If necessary, you can add it by using Additional Meta Tags
    • Related Issues #783
  • πŸ”§ More flexible customization of robots
    • Related Issues #753
  • ✨ Improved type definitions
    • Related Issues #796
  • πŸ‘¨β€πŸ’» Migration to monorepo
    • Related Issues #794

Migration Guide

  • noindex and nofollow properties have been removed. They can be controlled by using the robots property instead.

v2.x

<MetaTags noindex={true} nofollow={true} />

v3

<MetaTags robots="noindex,nofollow" />
  • googlebot is no longer included by default, so if you want to continue to enable the googlebot, write the following.
<MetaTags
  additionalMetaTags={[
    {
      name: 'googlebot',
      content: 'index,follow'
    }
  ]}
/>
  • <meta name="robots"> element can now be disabled completely.
<MetaTags
  robots={false}
/>

If you want to disable <meta name="robots"> and enable only <meta name="googlebot">, write the following.

<MetaTags
  robots={false}
  additionalMetaTags={[
    {
      name: 'googlebot',
      content: 'index,follow'
    }
  ]}
/>
  • robotsProps property has been renamed additionalRobotsProps.

v2.x

<MetaTags
  robotsProps={{
    nosnippet: true,
    notranslate: true,
    noimageindex: true,
    noarchive: true,
    maxSnippet: -1,
    maxImagePreview: 'none',
    maxVideoPreview: -1
  }}
/>

v3

<MetaTags
  additionalRobotsProps={{
    nosnippet: true,
    notranslate: true,
    noimageindex: true,
    noarchive: true,
    maxSnippet: -1,
    maxImagePreview: 'none',
    maxVideoPreview: -1
  }}
/>
  • openGraph.site_name has been renamed to openGraph.siteName.

Reasons:

  1. because site_name will be removed and siteName will be adopted in the next major version of next-seo.
  2. since only site_name had adopted the snake case, its interface was aligned with other properties.

v2.x

<MetaTags
  openGraph={{
    site_name: 'SiteName'
  }}
/>

v3

<MetaTags
  openGraph={{
    siteName: 'SiteName'
  }}
/>

Support custom `robots` and `googlebot` content

Description

In certain situations a developer might prefer passing a string to robots tags, or disabling the meta tag entirely.

Solution

Add a robots property and set meta tag content via string, or disable meta tags complete.

Alternatives

None that I can think of.

Duplicated tags with ssr

Describe the bug
I have a website with ssr. On each +page.svelte I have a . On dev it's working fine. If I build and run on prod - I have duplicated tags

This is is how every +page.svelte looks like:

import {LL, locale} from "./../i18n/i18n-svelte"


<<<< body>>>>


<MetaTags
	title="{$LL.pageTitle.main()}"
	description="{$LL.pageDescription.main()}"
	languageAlternates="{getHeadLinks($page.url.pathname, $locale).alternate}"
	canonical="{`https://mywebsite.com/${$locale}${removeLocaleFromPath(
		$page.url.pathname,
		$locale
	)}`}"
/>

** FUNCTIONS**


let LOCALES = ["de", "en"]; // IMPORANT ADD NEW LANG
export const getHeadLinks = (url: string, locale: string) => {
	url = removeLocaleFromPath(url, locale);
	let alternate = [
		{ hrefLang: "x-default", href: `https://mywebsite.com/${url}` },
		{ hrefLang: "de", href: `https://mywebsite.com/de${url}` },
		{ hrefLang: "en", href: `https://mywebsite.com/en${url}` }
	];
	return { alternate: alternate };
};

export const removeLocaleFromPath = (path: string, locale: string) => {
	for (let i = 0; i < LOCALES.length; i++) {
		path = path.replace(`/${LOCALES[i]}/`, "/");
	}
	for (let i = 0; i < LOCALES.length; i++) {
		if (path === `/${LOCALES[i]}`) {
			path = "";
		}
	}
	return path;
};

If I run the build with js turned off - there is only one instance of meta tag. Tho if I turn it on - the second one appears. When I goto anotherpage one instance of metatag changes its urls, and the other doesn't. So seems like the metatags injected 2 times - on server side and on client side. How do I turn it off ?

Add support for sapper/svelte-kit

Is your feature request related to a problem? Please describe.
The problem is that this awesome package is not usable in sapper/svelte-kit as most properties are static. Version 2.1 added support for a dynamic title but the rest of the properties are static.

For example I'm using stores to set the meta tags like this:

 <meta name="robots" content={$robots}/>

With this module I can set them like this:

<MetaTags robots={$robots} />

If I navigate now through my website and update the robot store, the value in the meta tag doesn't get updated when using this package. Using my own solution works.

Describe the solution you'd like
All properties should be dynamic so that on site navigation they can change.

Allow to set only name="robots" meta tag, or only name="googlebot" meta tag, or both

Is your feature request related to a problem? Please describe.

I would prefer not to include the name="googlebot" meta tag in the head tag, since the name="googlebot" meta tag is unnecessary if there is a name="robots" meta tag.

Describe the solution you'd like

I would like the feature to set either only the name="robots" meta tag or the name="googlebot" meta tag, or both.

Add charset attribute

To define the character encoding (HTML5):

<meta charset="utf-8">

Maybe like this:

<MetaTags charset="utf-8" />

Thanks 🀝

`<JsonLd>` is duplicated in the `<head>`

After adding the following code block (just a copy of the example) and inspecting the page the JsonLd seems to be inserted twice. When switching the output to body it inserts it once.

The code block,

<JsonLd
  schema={{
    '@type': 'Article',
    mainEntityOfPage: {
      '@type': 'WebPage',
      '@id': 'https://example.com/article',
    },
    headline: 'Article headline',
    image: [
      'https://example.com/photos/1x1/photo.jpg',
      'https://example.com/photos/4x3/photo.jpg',
      'https://example.com/photos/16x9/photo.jpg',
    ],
    datePublished: '2015-02-05T08:00:00+08:00',
    dateModified: '2015-02-05T09:20:00+08:00',
    author: {
      '@type': 'Person',
      name: 'John Doe',
    },
    publisher: {
      '@type': 'Organization',
      name: 'Google',
      logo: {
        '@type': 'ImageObject',
        url: 'https://example.com/logo.jpg',
      },
    },
  }}
/>

The actual result https://share.cleanshot.com/wAGeiykgk9BqhD7My5iP

My package.json,

{
  "name": "frontend",
  "version": "0.0.1",
  "scripts": {
    "dev": "env-cmd svelte-kit dev",
    "build": "svelte-kit build",
    "package": "svelte-kit package",
    "preview": "env-cmd svelte-kit preview",
    "prepare": "svelte-kit sync",
    "lint": "prettier --check --plugin-search-dir=. . && eslint .",
    "format": "prettier --write --plugin-search-dir=. ."
  },
  "devDependencies": {
    "@fullhuman/postcss-purgecss": "^4.1.3",
    "@sveltejs/adapter-node": "^1.0.0-next.78",
    "@sveltejs/kit": "next",
    "bootstrap": "^5.2.0-beta1",
    "cssnano": "^5.1.12",
    "env-cmd": "^10.1.0",
    "eslint": "^8.18.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-svelte3": "^4.0.0",
    "graphql-request": "^4.3.0",
    "postcss-load-config": "^4.0.1",
    "postcss-sort-media-queries": "^4.2.1",
    "prettier": "^2.7.1",
    "prettier-plugin-svelte": "^2.7.0",
    "sass": "^1.53.0",
    "stylelint-config-rational-order": "^0.1.2",
    "stylelint-config-standard": "^26.0.0",
    "stylelint-config-standard-scss": "^4.0.0",
    "stylelint-order": "^5.0.0",
    "stylelint-scss": "^4.2.0",
    "svelte": "^3.48.0",
    "svelte-body": "^1.3.6",
    "svelte-meta-tags": "^2.6.1",
    "svelte-preprocess": "^4.10.7",
    "svelte-recaptcha-v2": "^0.0.2"
  },
  "type": "module",
  "dependencies": {
    "@sendgrid/mail": "^7.7.0",
    "embla-carousel": "^6.2.0",
    "postcss-scss": "^4.0.4"
  }
}

Output JSON-LD inline

Is your feature request related to a problem? Please describe.
Currently JSON-LD is output in the document head only.

Describe the solution you'd like
I'd like the ability to output JSON-LD outside the head so I may group logical items together within a single element in my documents and reduce the time required to parse the document head. I'd expect this to be the default behavior with the ability to add to the head by dropping the tag into svelte:head.

Describe alternatives you've considered
Using Microformats to structure the data.

Additional context
Grouping items together in markup is good for copy/paste as well as scrapers. Some might not like it, which is why they would be be able to place in the head using existing facilities design for the purpose.

Not providing title property creates empty title tag

Describe the bug
If meta tags config does not include title property, the library will create empty <title></title> tag, which is unwanted in my opinion, because somebody (like me) could need to supply title on each individual page. In my case my website is translated meaning the titles are also translated dynamically by svelte-i18n, so naturally I need to access the locale stores in page component. I want to use the baseMetaTags approach from the readme example.

Reproduction

function getBaseTags(url) {
	const pageUrl = decodeURIComponent(new URL(url.pathname, url.origin).href)
	const description = 'Desc'
	return Object.freeze({
		description,
		canonical: pageUrl,
		openGraph: {
			type: 'website',
			url: pageUrl,
			locale: 'pl',
			title: 'AppName',
			description,
			siteName: 'AppName',
			images: [
				{
					url: `${url.origin}/meta_image_half.png`,
					width: 600,
					height: 315,
					type: 'image/png',
				},
				{
					url: `${url.origin}/meta_image_half.png`,
					width: 1200,
					height: 630,
					type: 'image/png',
				},
			],
		},
	})
}

result:
image

Additional context
I'm not sure how crawlers will react to having two title tags in head - could they grab the empty one first?

either im stupid or the og:image isnt working, how do i get that to show no matter what i do i cant find a way to have the image i made be displayed as the image you see when you share the link to my website

Describe the bug
A clear and concise description of what the bug is.

Reproduction
Provide a reproduction URL or steps to reproduce. If a report is vague and no reproduction is provided within a reasonable time-frame, the issue will be closed.

Additional context
Add any other context about the problem here.

What's on the roadmap?

Is your feature request related to a problem? Please describe.
I'm always frustrated when i don't see a roadmap for a project.

Describe the solution you'd like
Project should have a roadmap.

Describe alternatives you've considered
Project not having a roadmap.

Additional context
Most of the open source project i have come across have a roadmap.

Jokes aside, the project is actually awesome. It would be better if there was some planning for this project :)

Using variables

I'm using mdsvex and my markdown pages have variables:

---
layout: componentLayout
title: My Title
breadcrumb_title: My-breadcrumb
dir: Components
description: 'My description'
---

I can use them for some cases:

<MetaTags
  title={breadcrumb_title}
  titleTemplate="%s | Flowbite-Svelte"
  description={description}
...

But not in {{}}:

openGraph={{
    ...
    title: {title}, // this won't work
    description: {title},// this won't work
    images: [
      {
        ...
        alt: {title} // this won't work
      }
    ],
    site_name: 'Flowbite-Svelte'
  }}
  twitter={{
    ...
    title: {title},// this won't work
    description: {description},// this won't work
  ...
  }}

How can I use variables in {{}}?

JSONLD elements preserved between page change with SvelteKit

Describe the bug
I have multiple pages with FAQs and products.
When I navigate from page A with FAQ-A and products-A to page B, I get both FAQ-A, FAQ-B and products-A and products-B in my head markup.

The setup is the follwing:

I've created a helper function to generate the JSONLD content


export function generateProductJSONLD(service: Service, image: string): Partial<JsonLdProps> {
  const priceValidUntil = new Date()
  priceValidUntil.setFullYear(priceValidUntil.getFullYear() + 1)
  const jsonLD: Partial<JsonLdProps> = {
    schema: {
      "@context": "https://schema.org",
      "@type": "Product",
      name: service.name,
      description: service.description,
      image,
      url: '<redacted_base_url>' + service.selfLink,
      brand: {
        "@type": "Organization",
        "name": "<redacted>"
      },
      sku: service.name,
      offers: {
        "@type": "Offer",
        price: service.price,
        priceValidUntil,
        url: '<redacted_base_url>' + service.selfLink,
        priceCurrency: "NZD",
        availability: "https://schema.org/InStock",
      }
    }
  }

  return jsonLD
}


export function generateFAQJSONLD(faqs: FAQ[]): Partial<JsonLdProps> {
  const jsonLD: Partial<JsonLdProps> = {
    schema: {
      "@context": "https://schema.org",
      "@type": "FAQPage",
      mainEntity: faqs.map(faq => ({
        "@type": "Question",
        name: faq.question,
        acceptedAnswer: {
          "@type": "Answer",
          text: faq.answer
        }
      }))
    }
  }
  return jsonLD
}

This is then begin used in page A and page B

src/routes/services/pageA && src/routes/services/pageB:

<svelte:head>
	<title>Title</title>
</svelte:head>
<JsonLd {...generateFAQJSONLD(faqs)} />
<MetaTags {...generateMetaTags({ title: 'Title', description: "Description", url: '<redacted>' })} />

...HTML code...

{#each services.massage as service, idx}
<JsonLd {...generateProductJSONLD(service, serviceBanners[service.id])} />
....HTML code...

First time I navigate to page A, everything looks OK, but if I navigate to page B (using a simple html element, no fancy navigation), I then get all JSONLDs from page A and page B. Interestingly enough, the MetaTags are updated properly.

Reproduction
You can see it live at https://amelies.co.nz
navigate to services/massage, then using the menu, navigate to services/skin-and-makeup

Please let me know if I'm doing something zrong, or if there is a bug somewhere.

Docs: More practical examples

Is your feature request related to a problem? Please describe.
We will address users' concerns by showing more practical examples of using Svelte Meta Tags with SvelteKit.

Describe the solution you'd like
Add to README.mdand create an example directory and prepare practical examples.

Describe alternatives you've considered
No response

Additional context
No response

question: is there any reason to limit this package installation for pnpm only?

Hi, I really like this package as it's really like a next-seo equivalent for svelte projects, love what you're doing here.

One issue: I can't install this package unless I use pnpm. Pnpm is really a great choice and its blazing fast. But I believe there're some people out there (including me) who are still relying on yarn / npm as it's more supported for integrations with other platforms / toolings (deployment, automatic dependency updater, etc which not many have supported pnpm yet).

I see there's a commit where it limits to use pnpm only: afb29dd

Really appreciate if there're some explanations / reasons for it πŸ™

titleTemplate not used for <title> tag

Describe the bug
Setting titleTemplate to %s | Foo and title to Bar results in <title>Bar</title> not <title>Bar | Foo</title> like I'd expect

Reproduction
see above ^

Additional context
version 2.8.0

Keywords metatags

Keywords metatags

Meta keywords are meta tags that you can use to give search engines more information about a page's content

Currently there is no option to add Keywords to the MetaTag since it does not exist in type 'MetaTagsProps'

is there an option to support this kind of feature?

it is really easy to add it to this library and it really can boost your seo score.

Twitter:image

According to the Twitter doc, the image ratio changed to 1:1.
The current README has 2:1.

A URL to a unique image representing the content of the page. You should not use a generic image such as your website logo, author photo, or other image that spans multiple pages. Images for this Card support an aspect ratio of 1:1 with minimum dimensions of 144x144 or maximum of 4096x4096 pixels. Images must be less than 5MB in size. The image will be cropped to a square on all platforms. JPG, PNG, WEBP and GIF formats are supported. Only the first frame of an animated GIF will be used. SVG is not supported.

Conflicting results in svelte resolve configuration

Describe the bug
Hi, i was working on my project that uses this library, and I got this warning, which told me to report the issue to the library maintainers:

[vite-plugin-svelte] WARNING: The following packages use a svelte resolve configuration in package.json that has conflicting results and is going to cause problems future.

[email protected]

Please see https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#conflicts-in-svelte-resolve for details.

Reproduction
my project is open source at https://github.com/theonlytails/aura-lang/tree/main/packages/aura-site

What about the og namespace?

The <html prefix="og: https://ogp.me/ns#"> tag, must be added manually? Does the library consider handling it?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): lock file maintenance

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • pnpm/action-setup v4.0.0
  • actions/setup-node v4
.github/workflows/release.yml
  • actions/checkout v4
  • pnpm/action-setup v4.0.0
  • actions/setup-node v4
npm
example/package.json
  • @sveltejs/adapter-auto ^3.2.4
  • @sveltejs/kit ^2.5.24
  • @sveltejs/vite-plugin-svelte ^3.1.2
  • just-extend ^6.2.0
  • svelte ^4.2.18
  • svelte-check ^3.8.6
  • tslib ^2.6.3
  • typescript ^5.5.4
  • vite ^5.4.2
package.json
  • @changesets/cli ^2.27.7
  • @types/eslint ^9.6.0
  • eslint ^9.9.0
  • eslint-config-prettier ^9.1.0
  • eslint-plugin-svelte ^2.43.0
  • globals ^15.9.0
  • prettier ^3.3.3
  • prettier-plugin-svelte ^3.2.6
  • typescript-eslint ^8.2.0
  • pnpm ^9.8.0
  • pnpm 9.8.0
packages/svelte-meta-tags/package.json
  • schema-dts ^1.1.2
  • @sveltejs/adapter-auto ^3.2.4
  • @sveltejs/kit ^2.5.24
  • @sveltejs/package ^2.3.4
  • @sveltejs/vite-plugin-svelte ^3.1.2
  • publint ^0.2.10
  • svelte ^4.2.18
  • svelte-check ^3.8.6
  • tslib ^2.6.3
  • typescript ^5.5.4
  • vite ^5.4.2

  • Check this box to trigger a request for Renovate to run again on this repository

Separate JSON-LD from MetaTags component

Is your feature request related to a problem? Please describe.
This is inconvenient when dealing with multiple JSON-LDs.
If you use multiple <MetaTags/>, metadata such as the following will always be rendered and duplicated.

<meta name="robots" content="index,follow">.
<meta name="googlebot" content="index,follow">.

Describe the solution you'd like
Eliminates duplicate metadata and facilitates handling of multiple JSON-LDs.

Describe alternatives you've considered
Separate JsonLd from MetaTags.

Example of use

<script>
  import { MetaTags, JsonLd } from 'svelte-meta-tags';
</script>

<MetaTags title="JSON-LD Page Title | Svelte Meta Tags" description="Description of JSON-LD page" />

<JsonLd
  schema={{
    '@type': 'BreadcrumbList',
    itemListElement: [
      {
        '@type': 'ListItem',
        position: 1,
        name: 'Books',
        item: 'https://example.com/books'
      },
      {
        '@type': 'ListItem',
        position: 2,
        name: 'Science Fiction',
        item: 'https://example.com/books/sciencefiction'
      },
      {
        '@type': 'ListItem',
        position: 3,
        name: 'Award Winners'
      }
    ]
  }}
/>

<JsonLd
  schema={{
    '@type': 'NewsArticle',
    mainEntityOfPage: {
      '@type': 'WebPage',
      '@id': 'https://google.com/article'
    },
    headline: 'Article headline',
    image: [
      'https://example.com/photos/1x1/photo.jpg',
      'https://example.com/photos/4x3/photo.jpg',
      'https://example.com/photos/16x9/photo.jpg'
    ],
    datePublished: '2015-02-05T08:00:00+08:00',
    dateModified: '2015-02-05T09:20:00+08:00',
    author: {
      '@type': 'Person',
      name: 'John Doe'
    },
    publisher: {
      '@type': 'Organization',
      name: 'Google',
      logo: {
        '@type': 'ImageObject',
        url: 'https://google.com/logo.jpg'
      }
    }
  }}
/>

Additional context
Since this is a breaking change, we need to release version 2.0.0 and update the documentation.

Duplicate Json+ld in the bottom of the page

Describe the bug
Previously, I got Json+ld duplication in the header section of the HTML as everyone has reported. But after the update, it was gone until I saw Google Webmaster point out another duplication issue.

Reproduction
I have tried view-source tab, but I couldn't find it. But, when press F12 -> Element tab and search for specific schema.org tag like FAQPage, then I found one of the duplication at the bottom of my page and it's highlighted that it's added by a js file. Here is the page that I got every json+ld duplication issue OnlineAppZone.com.

Screenshot_20230601_100624

Additional context
svelte.config.js

...
import preprocess from "svelte-preprocess";

const config = {
 preprocess: [
    preprocess({
      postcss: true,
      preserve: ["ld+json"]
    })
  ]
};

package.json

...
"@sveltejs/kit": "^1.20.0",
"svelte": "^3.59.1",
"svelte-meta-tags": "^2.7.2",
"svelte-preprocess": "^5.0.4",
"vite": "^4.3.9"

Importing types and making them available

Is your feature request related to a problem? Please describe.
Currently, this is inconvenient if you want to import and use a type.

Describe the solution you'd like
type can be imported and used.

Describe alternatives you've considered
Example of use

<script lang="ts">
  import MetaTags, { JsonLd } from 'svelte-meta-tags';
  import type { MetaTagsProps, JsonLdProps } from 'svelte-meta-tags';

  const metatags: MetaTagsProps = {
    title: 'Types | Svelte Meta Tags',
    description: 'Description',
    canonical: 'https://www.canonical.ie/',
    openGraph: {
      type: 'website',
      url: 'https://www.example.com/page',
      locale: 'en_IE',
      title: 'Open Graph Title',
      description: 'Open Graph Description',
      images: [
        {
          url: 'https://www.example.ie/og-image.jpg',
          width: 800,
          height: 600,
          alt: 'Og Image Alt'
        }
      ],
      site_name: 'SiteName'
    },
    twitter: {
      handle: '@handle',
      site: '@site',
      cardType: 'summary_large_image'
    },
    facebook: {
      appId: '1234567890'
    }
  };

  const jsonld: JsonLdProps = {
    schema: {
      '@type': 'NewsArticle',
      mainEntityOfPage: {
        '@type': 'WebPage',
        '@id': 'https://google.com/article'
      },
      headline: 'Article headline',
      image: [
        'https://example.com/photos/1x1/photo.jpg',
        'https://example.com/photos/4x3/photo.jpg',
        'https://example.com/photos/16x9/photo.jpg'
      ],
      datePublished: '2015-02-05T08:00:00+08:00',
      dateModified: '2015-02-05T09:20:00+08:00',
      author: {
        '@type': 'Person',
        name: 'John Doe'
      },
      publisher: {
        '@type': 'Organization',
        name: 'Google',
        logo: {
          '@type': 'ImageObject',
          url: 'https://google.com/logo.jpg'
        }
      }
    }
  };
</script>

<MetaTags {...metatags} />

<JsonLd {...jsonld} />

Additional context
You might want to update the documentation as well.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: packageRules:
You have included an unsupported manager in a package rule. Your list: pnpm.
Supported managers are: (ansible, ansible-galaxy, argocd, asdf, azure-pipelines, batect, batect-wrapper, bazel, bazel-module, bazelisk, bicep, bitbucket-pipelines, buildkite, bun, bundler, cake, cargo, cdnurl, circleci, cloudbuild, cocoapods, composer, conan, cpanfile, crossplane, deps-edn, docker-compose, dockerfile, droneci, fleet, flux, fvm, git-submodules, github-actions, gitlabci, gitlabci-include, gomod, gradle, gradle-wrapper, helm-requirements, helm-values, helmfile, helmsman, helmv3, hermit, homebrew, html, jenkins, jsonnet-bundler, kotlin-script, kubernetes, kustomize, leiningen, maven, maven-wrapper, meteor, mint, mix, nix, nodenv, npm, nuget, nvm, ocb, osgi, pep621, pip-compile, pip_requirements, pip_setup, pipenv, poetry, pre-commit, pub, puppet, pyenv, ruby-version, sbt, scalafmt, setup-cfg, swift, tekton, terraform, terraform-version, terragrunt, terragrunt-version, tflint-plugin, travis, velaci, vendir, woodpecker, regex).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.