Skip to content

Commit 4e0e75d

Browse files
committed
fix: warn about first i18n usage
Fixes #215
1 parent 0a70312 commit 4e0e75d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/core/src/puppeteer/tasks/html.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export function processSeoMeta($: CheerioAPI): HTMLExtractPayload {
9696
}
9797

9898
export const inspectHtmlTask: PuppeteerTask = async (props) => {
99-
const { resolvedConfig, hooks, runtimeSettings } = useUnlighthouse()
99+
const unlighthouse = useUnlighthouse()
100+
const { resolvedConfig, hooks, runtimeSettings } = unlighthouse
100101
const { page, data: routeReport } = props
101102
const logger = useLogger()
102103
let html: string
@@ -140,9 +141,14 @@ export const inspectHtmlTask: PuppeteerTask = async (props) => {
140141
routeReport.seo = processSeoMeta($)
141142
if (resolvedConfig.scanner.ignoreI18nPages && routeReport.seo.alternativeLangDefault && withoutTrailingSlash(routeReport.route.url) !== withoutTrailingSlash(routeReport.seo.alternativeLangDefault)) {
142143
routeReport.tasks.inspectHtmlTask = 'ignore'
143-
logger.debug(`Page has an alternative lang, ignoring \`${routeReport.route.path}\`: ${routeReport.seo.alternativeLangDefault}`)
144+
if (!unlighthouse._i18nWarn) {
145+
unlighthouse._i18nWarn = true
146+
logger.warn(`Page has an alternative lang, ignoring \`${routeReport.route.path}\`: ${routeReport.seo.alternativeLangDefault}. You can disable this behavior with the \`scanner.ignoreI18nPages = true\` option. Future warnings will be suppressed.`)
147+
}
148+
else {
149+
logger.debug(`Page has an alternative lang, ignoring \`${routeReport.route.path}\`: ${routeReport.seo.alternativeLangDefault}`)
150+
}
144151
// make sure we queue the default, this fixes issues with if the home page has a default lang that is alternative
145-
const unlighthouse = useUnlighthouse()
146152
unlighthouse.worker.queueRoute(normaliseRoute(routeReport.seo.alternativeLangDefault))
147153
return routeReport
148154
}

packages/core/src/types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -881,4 +881,8 @@ export interface UnlighthouseContext {
881881
* @internal
882882
*/
883883
_axios?: AxiosInstance
884+
/**
885+
* @internal
886+
*/
887+
_i18nWarn?: boolean
884888
}

0 commit comments

Comments
 (0)