-
Notifications
You must be signed in to change notification settings - Fork 19
Make meta titles short #5603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Make meta titles short #5603
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7c0e1f1
shorten Meta Titles
sumitshinde-84 e67d906
Revert accidental package-lock.json churn and remove stray blog file …
sumitshinde-84 b287395
drop unused metaTitle in base.njk, clarify length guidance
sumitshinde-84 986685b
add meta title support
sumitshinde-84 a309ee1
Fix stale suffix wording after rebase onto Yndira's title-suffix unif…
ZJvandeWeg e360504
Clarify metaTitle's 60-char limit applies before the suffix, matching…
ZJvandeWeg 9190c6e
Add CI test enforcing the metaTitle length limit documented in the ha…
ZJvandeWeg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Enforces the metaTitle length guidance documented in | ||
| // nuxt/content/handbook/marketing/content-strategy/blog.md#meta-title. | ||
| // Kept free of Nuxt imports so `node --test` can run it directly. | ||
|
|
||
| import { readFileSync, readdirSync, statSync } from 'node:fs' | ||
| import { join } from 'node:path' | ||
| import yaml from 'js-yaml' | ||
|
|
||
| // Google truncates search-result titles at roughly this width; metaTitle is meant to fit | ||
| // on its own, before the ` • FlowFuse Blog`/`FlowFuse Changelog` suffix is appended. | ||
| export const MAX_META_TITLE_LENGTH = 60 | ||
|
|
||
| /** Recursively lists every `.md` file under `dir`. */ | ||
| function listMarkdownFiles (dir) { | ||
| return readdirSync(dir, { withFileTypes: true }).flatMap(entry => { | ||
| const path = join(dir, entry.name) | ||
| if (entry.isDirectory()) return listMarkdownFiles(path) | ||
| return entry.isFile() && entry.name.endsWith('.md') ? [path] : [] | ||
| }) | ||
| } | ||
|
|
||
| /** Parses the YAML frontmatter of a markdown file, or `null` if it has none. */ | ||
| export function readFrontmatter (filePath) { | ||
| const content = readFileSync(filePath, 'utf8') | ||
| const match = content.match(/^---\n([\s\S]*?)\n---/) | ||
| return match ? yaml.load(match[1]) : null | ||
| } | ||
|
|
||
| /** | ||
| * Every `metaTitle` under `dir` (recursively) that exceeds MAX_META_TITLE_LENGTH characters. | ||
| * Files with no `metaTitle` set are skipped - only authors who set the field are held to it. | ||
| */ | ||
| export function findOverlongMetaTitles (dir) { | ||
| return listMarkdownFiles(dir) | ||
| .map(file => ({ file, metaTitle: readFrontmatter(file)?.metaTitle })) | ||
| .filter(({ metaTitle }) => typeof metaTitle === 'string' && metaTitle.length > MAX_META_TITLE_LENGTH) | ||
| .map(({ file, metaTitle }) => ({ file, metaTitle, length: metaTitle.length })) | ||
| } | ||
|
|
||
| export function isDirectory (path) { | ||
| try { | ||
| return statSync(path).isDirectory() | ||
| } catch { | ||
| return false | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { test } from 'node:test' | ||
| import assert from 'node:assert/strict' | ||
| import { fileURLToPath } from 'node:url' | ||
| import { dirname, join } from 'node:path' | ||
|
|
||
| import { MAX_META_TITLE_LENGTH, findOverlongMetaTitles, isDirectory } from './meta-title-length.mjs' | ||
|
|
||
| const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '../..') | ||
| const blogDir = join(repoRoot, 'src/blog') | ||
| const changelogDir = join(repoRoot, 'src/changelog') | ||
|
|
||
| // Guards the fixture-free tests below against a silent no-op if the source layout moves. | ||
| test('src/blog and src/changelog exist where these tests expect them', () => { | ||
| assert.ok(isDirectory(blogDir), `expected ${blogDir} to exist`) | ||
| assert.ok(isDirectory(changelogDir), `expected ${changelogDir} to exist`) | ||
| }) | ||
|
|
||
| test('every blog post metaTitle fits within the handbook-documented length limit', () => { | ||
| const violations = findOverlongMetaTitles(blogDir) | ||
| assert.deepEqual(violations, [], formatViolations(violations)) | ||
| }) | ||
|
|
||
| test('every changelog entry metaTitle fits within the handbook-documented length limit', () => { | ||
| const violations = findOverlongMetaTitles(changelogDir) | ||
| assert.deepEqual(violations, [], formatViolations(violations)) | ||
| }) | ||
|
|
||
| function formatViolations (violations) { | ||
| return violations | ||
| .map(({ file, metaTitle, length }) => `${file}: "${metaTitle}" is ${length} chars (max ${MAX_META_TITLE_LENGTH})`) | ||
| .join('\n') | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/blog/2023/07/how-to-build-a-opc-client-dashboard-in-node-red.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/blog/2023/07/how-to-deploy-a-basic-opc-ua-server-in-node-red.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/blog/2023/08/isa-95-automation-pyramid-to-unified-namespace.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/blog/2024/01/how-to-deploy-node-red-with-flowfuse-to-balenacloud.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...03/flowfuse-gallarus-strategic-partnership-to-accelerate-industry-4-adoption.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/blog/2024/03/scaling-node-red-devices-vs-flowfuse-instance.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/blog/2024/04/building-an-admin-panel-in-node-red-with-dashboard-2.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/blog/2024/04/how-to-build-an-application-with-node-red-dashboard-2.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/blog/2024/05/node-red-dashboard-2-layout-navigation-styling.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...log/2024/05/understanding-node-flow-global-environment-variables-in-node-red.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.