Skip to content

Instantly share code, notes, and snippets.

@varyen
Last active March 27, 2019 19:14
Show Gist options
  • Save varyen/c266fa349b47fa43ac4ad0831d8d6021 to your computer and use it in GitHub Desktop.
Save varyen/c266fa349b47fa43ac4ad0831d8d6021 to your computer and use it in GitHub Desktop.
Vue component: prevent childs from indexing by crawlers
export default {
name: 'NoIndex',
functional: true,
props: {
tag: {
type: String,
default: 'div',
},
},
render(h, {children, props}) {
const comment1 = h('');
comment1.text = 'googleoff: all';
const comment2 = h('');
comment2.text = 'noindex';
const comment3 = h('');
comment3.text = '/noindex';
const comment4 = h('');
comment4.text = 'googleon: all';
return h(props.tag, {
class: ['robots-noindex'],
}, [comment1, comment2, ...children, comment3, comment4]);
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment