s% 如何引用 Helmet 组件内部的 title 属性?

How does s% reference the title attribute inside the Helmet component?

你能帮我理解 %s 如何在 gatsby 入门主题的 <Helmet /> 组件中引用 <SEO /> 组件的标题属性吗?

https://github.com/gatsbyjs/gatsby-starter-default/blob/master/src/components/seo.js

第 19 行:

titleTemplate={`%s | ${data.site.siteMetadata.title}`}

模式 %s 用于替换 string:

const str = 'world';
console.log('Hello %s!', str);

$s 是从组件的 "title" 属性推断出来的。

这里有一个link相关的源代码:

https://github.com/nfl/react-helmet/blob/b79d30ff44c7ff3c175c31059076e5e549a1b402/src/HelmetUtils.js#L27