feat!: render the post page on the shared SEO layer with one H1 in both Journal H1 modes (tracer)
- extend vue-seo-layer (link dependency during development) and drop
@nuxtjs/seo: the page head, canonical and the one JSON-LD graph come
from the CMS resolve answer; the post's own title, excerpt and image
apply only while there is no CMS answer
- remove the journal sitemap source and the copied shared purge route,
library and plugin (the SEO layer serves POST /api/__site__/cache/purge);
the deprecated POST /api/__journal__/cache/purge keeps working
- post title is h1 while the Journal API reports content_h1_to_h2 on
(or absent) and p.journal-post__title while off; journal.postTitleTag
('auto' | 'h1' | 'p') overrides it; body h1 headings are demoted to h2
while the setting is on (gateJournalHtml/sanitizeJournalHtml demoteH1)
- journal.breadcrumbs option and post-title CSS tokens
- smoke harness: count=, header=, noheader= and resolves lines; the
fixture API also answers the SEO resolve and site endpoints
BREAKING CHANGE: the layer no longer installs @nuxtjs/seo (no
nuxt-site-config, nuxt-schema-org, robots or sitemap module, no
/api/__sitemap__/journal source, no useSiteConfig()); apps take their
head, sitemaps and robots from the SEO plugin through vue-seo-layer.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { defineNuxtModule, extendPages } from 'nuxt/kit'
|
||||
import { DEFAULT_JOURNAL_ROUTES, JOURNAL_ROUTE_NAMES, normalizeJournalRoutes } from '../app/utils/routes.ts'
|
||||
import type { JournalModuleOptions, JournalRoutes } from '../app/utils/types.ts'
|
||||
import type { JournalModuleOptions, JournalPostTitleTag, JournalRoutes } from '../app/utils/types.ts'
|
||||
|
||||
const PAGE_FILES: Record<keyof JournalRoutes, string> = {
|
||||
index: 'PostIndexPage',
|
||||
@@ -33,6 +33,11 @@ function enabledLocaleCodes(locales: unknown): string[] {
|
||||
.filter((c): c is string => typeof c === 'string')
|
||||
}
|
||||
|
||||
/** journal.postTitleTag: 'h1' or 'p' as given, anything else 'auto'. */
|
||||
function postTitleTag(value: unknown): JournalPostTitleTag {
|
||||
return value === 'h1' || value === 'p' ? value : 'auto'
|
||||
}
|
||||
|
||||
export default defineNuxtModule<JournalModuleOptions>({
|
||||
meta: {
|
||||
name: 'vue-journal-layer',
|
||||
@@ -44,6 +49,8 @@ export default defineNuxtModule<JournalModuleOptions>({
|
||||
sort: 'published_at desc',
|
||||
relatedCount: 3,
|
||||
rss: true,
|
||||
postTitleTag: 'auto',
|
||||
breadcrumbs: true,
|
||||
},
|
||||
setup(options, nuxt) {
|
||||
const routes = normalizeJournalRoutes(options.routes as unknown as Record<string, unknown>)
|
||||
@@ -58,9 +65,11 @@ export default defineNuxtModule<JournalModuleOptions>({
|
||||
|
||||
// The search page renders per ?q, so it is never route-cached: Nitro's
|
||||
// cache keys by path, and an app rule such as '/**': { swr } would serve
|
||||
// one query's results for every query. It is noindex, follow and left
|
||||
// out of the sitemap. The locale-prefixed copies get the same rules. An
|
||||
// app's own rule for the path wins key by key.
|
||||
// one query's results for every query. It is noindex, follow (the
|
||||
// page's own meta sets that through vue-seo-layer; the robots rule and
|
||||
// the sitemap exclude serve an app that adds nuxt-robots or
|
||||
// @nuxtjs/sitemap itself). The locale-prefixed copies get the same
|
||||
// rules. An app's own rule for the path wins key by key.
|
||||
if (routes.search !== false) {
|
||||
const i18n = (nuxt.options as { i18n?: { locales?: unknown } }).i18n
|
||||
const paths = [routes.search, ...enabledLocaleCodes(i18n?.locales).map((code) => `/${code}${routes.search}`)]
|
||||
@@ -95,6 +104,8 @@ export default defineNuxtModule<JournalModuleOptions>({
|
||||
sort: options.sort,
|
||||
relatedCount: options.relatedCount,
|
||||
rss: options.rss,
|
||||
postTitleTag: postTitleTag(options.postTitleTag),
|
||||
breadcrumbs: options.breadcrumbs !== false,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user