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

Composable idea: HTML meta #317

Open
rijkvanzanten opened this issue May 26, 2020 · 3 comments
Open

Composable idea: HTML meta #317

rijkvanzanten opened this issue May 26, 2020 · 3 comments

Comments

@rijkvanzanten
Copy link

Hi there!

I came across the need of dynamically updating the html's meta tag and instead of running straight to the great vue-meta I figured to have a look over here to see if there was a Vue composable available already.

Is this something you'd be interested in adding to vue-composable? I can provide a pull request to implement it if you'd like 🙂

@rijkvanzanten rijkvanzanten changed the title Composable idea: window title Composable idea: HTML meta May 26, 2020
@pikax
Copy link
Owner

pikax commented May 26, 2020

Hello there 🙂

New composables and ideas are always welcome.

What's your idea for the API?

@rijkvanzanten
Copy link
Author

I was thinking we could add a useHead function that takes an object of different head tag-types with values:

const title = computed(() => `${props.page}  | My Website`);

const meta = reactive([
  {
    name: 'description',
    content: 'We are developers that build things'
  },
  {
    name: 'robots',
    content: 'nofollow'
  }
]);

useHead({
  title: title,
  meta: meta,
});

This would also allow us to later on add support for other tags you might find in <head> like link and script


Alternatively, we can split them up in dedicated composables like:

const title = ref('About Us');

useTitle(title);
const meta = reactive([
  {
    name: 'description',
    content: 'We are developers that build things'
  },
  {
    name: 'robots',
    content: 'nofollow'
  }
]);

useMeta(meta);

@pikax
Copy link
Owner

pikax commented May 26, 2020

Sounds good, we could have both, where the useHead would use the useMeta and useTitle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants