-
-
Notifications
You must be signed in to change notification settings - Fork 304
fix: standard.site fixes #1901
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
fix: standard.site fixes #1901
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||||||||||
| <script setup lang="ts"> | ||||||||||||||||||||
| import type { BlogPostFrontmatter } from '#shared/schemas/blog' | ||||||||||||||||||||
| import { generateBlogTID } from '#shared/utils/atproto' | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const props = defineProps<{ | ||||||||||||||||||||
| frontmatter: BlogPostFrontmatter | ||||||||||||||||||||
|
|
@@ -14,6 +15,15 @@ useSeoMeta({ | |||||||||||||||||||
| ...(props.frontmatter.draft ? { robots: 'noindex, nofollow' } : {}), | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cd app/components/global && wc -l BlogPostWrapper.vueRepository: npmx-dev/npmx.dev Length of output: 83 🏁 Script executed: cd app/components/global && cat -n BlogPostWrapper.vue | sed -n '1,50p'Repository: npmx-dev/npmx.dev Length of output: 2026 🏁 Script executed: cd app/components/global && grep -r "site.standard.document" --include="*.ts" --include="*.tsx" --include="*.vue" --include="*.js" | head -20Repository: npmx-dev/npmx.dev Length of output: 263 🏁 Script executed: grep -r "NPMX_DEV_DID" --include="*.ts" --include="*.tsx" --include="*.vue" --include="*.js" | head -10Repository: npmx-dev/npmx.dev Length of output: 670 🏁 Script executed: grep -r "generateBlogTID" --include="*.ts" --include="*.tsx" --include="*.vue" --include="*.js" -A 3 | head -30Repository: npmx-dev/npmx.dev Length of output: 1466 🏁 Script executed: cat app/modules/standard-site-sync.tsRepository: npmx-dev/npmx.dev Length of output: 126 🏁 Script executed: grep -r "frontmatter.draft" --include="*.ts" --include="*.tsx" --include="*.vue" --include="*.js" -B 2 -A 2Repository: npmx-dev/npmx.dev Length of output: 849 🏁 Script executed: fd "standard-site-sync" --type fRepository: npmx-dev/npmx.dev Length of output: 90 🏁 Script executed: fd "modules" --type d | head -5Repository: npmx-dev/npmx.dev Length of output: 69 🏁 Script executed: cat modules/standard-site-sync.tsRepository: npmx-dev/npmx.dev Length of output: 9654 Guard Line 15 prevents search engine indexing of drafts with Proposed fix-useHead({
- link: [
- {
- rel: 'site.standard.document',
- href: `at://${NPMX_DEV_DID}/site.standard.document/${generateBlogTID(props.frontmatter.date, props.frontmatter.slug)}`,
- },
- ],
-})
+if (!props.frontmatter.draft) {
+ useHead({
+ link: [
+ {
+ rel: 'site.standard.document',
+ href: `at://${NPMX_DEV_DID}/site.standard.document/${generateBlogTID(props.frontmatter.date, props.frontmatter.slug)}`,
+ },
+ ],
+ })
+}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
| }) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| useHead({ | ||||||||||||||||||||
| link: [ | ||||||||||||||||||||
| { | ||||||||||||||||||||
| rel: 'site.standard.document', | ||||||||||||||||||||
| href: `at://${NPMX_DEV_DID}/site.standard.document/${generateBlogTID(props.frontmatter.date, props.frontmatter.slug)}`, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| ], | ||||||||||||||||||||
| }) | ||||||||||||||||||||
|
Comment on lines
+18
to
+25
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should probably be done only for production
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| defineOgImageComponent('BlogPost', { | ||||||||||||||||||||
| title: props.frontmatter.title, | ||||||||||||||||||||
| authors: props.frontmatter.authors, | ||||||||||||||||||||
|
|
||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,6 @@ | ||||||||
| import { npmxPublicationRkey } from '#shared/utils/atproto' | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n server/routes/.well-known/site.standard.publication.get.tsRepository: npmx-dev/npmx.dev Length of output: 357 🏁 Script executed: rg "NPMX_DEV_DID" --type ts --type tsx -A 2 -B 2Repository: npmx-dev/npmx.dev Length of output: 88 🏁 Script executed: rg "NPMX_DEV_DID" -A 2 -B 2Repository: npmx-dev/npmx.dev Length of output: 1638 🏁 Script executed: rg "defineEventHandler|setResponseHeader" shared/utils/constants.tsRepository: npmx-dev/npmx.dev Length of output: 43 🏁 Script executed: fd "nuxt.config" -type fRepository: npmx-dev/npmx.dev Length of output: 231 🏁 Script executed: grep -r "auto-import\|defineEventHandler" . --include="*.config.*" --include="*.json" 2>/dev/null | head -20Repository: npmx-dev/npmx.dev Length of output: 43 🏁 Script executed: find server/routes -name "*.ts" -type f | head -5 | xargs catRepository: npmx-dev/npmx.dev Length of output: 3058 🏁 Script executed: cat -n server/routes/.well-known/site.standard.publication.get.ts | head -10Repository: npmx-dev/npmx.dev Length of output: 357 Import Line 5 references Proposed fix import { npmxPublicationRkey } from '#shared/utils/atproto'
+import { NPMX_DEV_DID } from '#shared/utils/constants'📝 Committable suggestion
Suggested change
|
||||||||
|
|
||||||||
| export default defineEventHandler(async event => { | ||||||||
| setResponseHeader(event, 'content-type', 'text/plain') | ||||||||
| return `at://${NPMX_DEV_DID}/site.standard.publication/${npmxPublicationRkey()}` | ||||||||
| }) | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { TID_CLOCK_ID } from './constants' | ||
| import * as TID from '@atcute/tid' | ||
|
|
||
| const ONE_DAY_MILLISECONDS = 86400000 | ||
| const MS_TO_MICROSECONDS = 1000 | ||
|
|
||
| // A very simple hasher to get an offset for blog posts on the same day | ||
| const simpleHash = (str: string): number => { | ||
| let h = 0 | ||
| for (let i = 0; i < str.length; i++) { | ||
| h = ((h << 5) - h + str.charCodeAt(i)) >>> 0 | ||
| } | ||
| return h | ||
| } | ||
|
|
||
| // Parse date from frontmatter, add slug-path entropy for same-date collision resolution | ||
| export const generateBlogTID = (dateString: string, slug: string): string => { | ||
| let timestamp = new Date(dateString).getTime() | ||
|
|
||
| if (timestamp % ONE_DAY_MILLISECONDS === 0) { | ||
| const offset = simpleHash(slug) % 1000000 | ||
| timestamp += offset | ||
| } | ||
|
|
||
| // Clock id(3) needs to be the same everytime to get the same TID from a timestamp | ||
| return TID.create(timestamp * MS_TO_MICROSECONDS, TID_CLOCK_ID) | ||
| } | ||
|
|
||
| // Using our release date as the tid for the publication | ||
| export const npmxPublicationRkey = () => | ||
| TID.create(new Date('2026-03-03').getTime() * MS_TO_MICROSECONDS, TID_CLOCK_ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
cat -n app/components/global/BlogPostWrapper.vue | head -30Repository: npmx-dev/npmx.dev
Length of output: 1162
🏁 Script executed:
Repository: npmx-dev/npmx.dev
Length of output: 231
🏁 Script executed:
rg "NPMX_DEV_DID" --type ts --type js -B 2 -A 2Repository: npmx-dev/npmx.dev
Length of output: 1638
Import
NPMX_DEV_DIDbefore using it on line 22.The constant is used in the
useHeadblock but not imported, which will fail type-checking and the build.Proposed fix
import type { BlogPostFrontmatter } from '#shared/schemas/blog' import { generateBlogTID } from '#shared/utils/atproto' +import { NPMX_DEV_DID } from '#shared/utils/constants'📝 Committable suggestion