auto: PR for feat/export-bundle-phase7-perf-seo #64
@@ -2,7 +2,7 @@ import type { Page, FormField } from '@/lib/schema/page'
|
|||||||
import type { AssetManager } from '@/lib/assets/assetManager'
|
import type { AssetManager } from '@/lib/assets/assetManager'
|
||||||
|
|
||||||
export type Exported = { html: string; css: string; js: string }
|
export type Exported = { html: string; css: string; js: string }
|
||||||
export type ExportOptions = { assetManager?: AssetManager; fontPreconnect?: boolean }
|
export type ExportOptions = { assetManager?: AssetManager; fontPreconnect?: boolean; robotsMeta?: string }
|
||||||
|
|
||||||
function renderFaq(section: { props: { items: Array<{ q: string; a: string }> } }) {
|
function renderFaq(section: { props: { items: Array<{ q: string; a: string }> } }) {
|
||||||
const itemsRaw: Array<{ q: string; a: string }> = Array.isArray(section.props.items) ? section.props.items : []
|
const itemsRaw: Array<{ q: string; a: string }> = Array.isArray(section.props.items) ? section.props.items : []
|
||||||
@@ -251,6 +251,7 @@ function buildHead(page: Page, opts?: ExportOptions) {
|
|||||||
}
|
}
|
||||||
const custom = page.analytics?.customHeadHtml || ''
|
const custom = page.analytics?.customHeadHtml || ''
|
||||||
const preconnect = opts?.fontPreconnect !== false
|
const preconnect = opts?.fontPreconnect !== false
|
||||||
|
const robotsMeta = (opts?.robotsMeta && opts.robotsMeta.trim().length > 0) ? `<meta name="robots" content="${escapeHtml(opts!.robotsMeta!)}" />` : ''
|
||||||
return `
|
return `
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
@@ -259,6 +260,7 @@ function buildHead(page: Page, opts?: ExportOptions) {
|
|||||||
${preconnect ? '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />' : ''}
|
${preconnect ? '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />' : ''}
|
||||||
<link rel="manifest" href="/site.webmanifest" />
|
<link rel="manifest" href="/site.webmanifest" />
|
||||||
<meta name="theme-color" content="${escapeHtml(page.theme.primaryColor)}" />
|
<meta name="theme-color" content="${escapeHtml(page.theme.primaryColor)}" />
|
||||||
|
${robotsMeta}
|
||||||
<title>${escapeHtml(page.seo.title)}</title>
|
<title>${escapeHtml(page.seo.title)}</title>
|
||||||
<meta name="description" content="${escapeHtml(page.seo.description)}" />
|
<meta name="description" content="${escapeHtml(page.seo.description)}" />
|
||||||
<meta property="og:title" content="${escapeHtml(page.seo.title)}" />
|
<meta property="og:title" content="${escapeHtml(page.seo.title)}" />
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { describe, it, expect } from 'vitest'
|
||||||
|
import { exportPage, type ExportOptions } from '@/lib/exporter/html'
|
||||||
|
import { pageSchema, type Page } from '@/lib/schema/page'
|
||||||
|
|
||||||
|
function makePage(): Page {
|
||||||
|
return pageSchema.parse({
|
||||||
|
title: 'Meta Robots',
|
||||||
|
locale: 'en',
|
||||||
|
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
|
||||||
|
sections: [ { type: 'hero', props: { heading: 'Hello', subheading: 'World', imageUrl: 'https://img/h.png' } } ],
|
||||||
|
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
||||||
|
seo: { title: 't', description: 'd' },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('meta robots', () => {
|
||||||
|
it('기본적으로 head에 robots 메타가 없다', () => {
|
||||||
|
const page = makePage()
|
||||||
|
const out = exportPage(page)
|
||||||
|
expect(out.html).not.toContain('<meta name="robots"')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('옵션으로 robots 메타를 삽입할 수 있다', () => {
|
||||||
|
const page = makePage()
|
||||||
|
const opts: ExportOptions = { robotsMeta: 'noindex,nofollow' }
|
||||||
|
const out = exportPage(page, opts)
|
||||||
|
expect(out.html).toContain('<meta name="robots" content="noindex,nofollow" />')
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user