Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion nuxt/components/ExploreMoreContent.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { isFuturePost } from '~/composables/useBlogList'
import { useIsFuturePost } from '~/composables/useBlogList'

// Ported from src/_includes/explore-more-content.njk: the blog / webinar / newsletter
// row. Named for the thank-you pages when it was extracted for them; the homepage renders
Expand All @@ -11,6 +11,8 @@ const props = defineProps<{
hubspotReference: string
}>()

const isFuturePost = useIsFuturePost()

const { data: blogPosts } = await useAsyncData(`explore-more-blog-${props.collectionName || 'all'}`, async () => {
const all = await queryCollection('blog')
.select('path', 'title', 'date', 'tags')
Expand Down
11 changes: 9 additions & 2 deletions nuxt/composables/useBlogList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ export const BLOG_TAG_TOPICS: Record<string, string> = {
// time (see nuxt.config.ts) rather than read from process.env here: a scheduled post gets no
// prerendered file, so its URL is served by the Netlify function, where process.env.CONTEXT
// is always undefined. That switched this check off and served the post before its date.
export function isFuturePost(date: string | Date): boolean {
return new Date(date) > new Date() && useRuntimeConfig().public.isProductionContext
export function isFuturePost(date: string | Date, isProductionContext: boolean): boolean {
return isProductionContext && new Date(date) > new Date()
}

// Call in setup, before any await: useRuntimeConfig() throws inside an async callback.
export function useIsFuturePost(): (date: string | Date) => boolean {
const isProductionContext = useRuntimeConfig().public.isProductionContext
return date => isFuturePost(date, isProductionContext)
}

export function useBlogList(tag: string | null, pageNumber: number) {
const isFuturePost = useIsFuturePost()
const { data: allEntries } = useAsyncData(
tag ? `blog-all-${tag}` : 'blog-all',
async () => {
Expand Down
6 changes: 4 additions & 2 deletions nuxt/pages/blog/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { BLOG_TAG_TOPICS, BLOG_TAGS, isFuturePost } from '../../composables/useBlogList'
import { BLOG_TAG_TOPICS, BLOG_TAGS, useIsFuturePost } from '../../composables/useBlogList'
import { getAllBlogPosts } from '../../utils/sharedContent'
// Handed to ContentRenderer explicitly below. Nuxt Content resolves a markdown component tag
// against a registry it builds while parsing, and reaches it through an async loader. These
Expand All @@ -12,6 +12,7 @@ import { faqAnswerText } from '../../lib/faq-answer.mjs'
definePageMeta({ layout: 'default' })

const route = useRoute()
const isFuturePost = useIsFuturePost()
const slugParts = computed(() => (Array.isArray(route.params.slug) ? route.params.slug : [route.params.slug]).filter(Boolean))

const routeInfo = computed(() => {
Expand Down Expand Up @@ -56,7 +57,8 @@ const { data: allPosts } = await useAsyncData(
const all = await getAllBlogPosts()
// Only the fields this page needs travel into its payload; the shared cache
// itself holds the wider field set other pages (listing, author) need.
return all.map(post => ({ path: post.path, title: post.title, date: post.date, tags: post.tags }))
return all.filter(post => !isFuturePost(post.date))
.map(post => ({ path: post.path, title: post.title, date: post.date, tags: post.tags }))
}
)

Expand Down
3 changes: 2 additions & 1 deletion nuxt/pages/blog/author/[slug].vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script setup lang="ts">
import { isFuturePost } from '../../../composables/useBlogList'
import { useIsFuturePost } from '../../../composables/useBlogList'
import { getAllBlogPosts } from '../../../utils/sharedContent'

definePageMeta({ layout: 'default' })

const route = useRoute()
const isFuturePost = useIsFuturePost()
const slug = computed(() => String(route.params.slug))

const author = computed(() => useTeamMember(slug.value))
Expand Down
9 changes: 8 additions & 1 deletion nuxt/server/utils/integrations-enrich.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ function rewriteRelativeAssets (readme: string, owner?: string, repo?: string):
})
}

// A heading that starts or ends with an emoji slugs with a stray hyphen ("🇬🇧 Overview" ->
// "-overview"), so a README's own "#overview" link would miss it.
function normalizeAnchor (id: string): string {
return id.replace(/\./g, '').replace(/^-+|-+$/g, '')
}

function rewriteIntegrationLinks (html: string, node: Integration): string {
if (!html) return html

Expand All @@ -324,8 +330,9 @@ function rewriteIntegrationLinks (html: string, node: Integration): string {
if (url.startsWith('#')) {
const target = url.slice(1)
if (!anchorIds.has(target)) {
const wanted = normalizeAnchor(target)
for (const existing of anchorIds) {
if (existing.replace(/\./g, '') === target) {
if (normalizeAnchor(existing) === wanted) {
return `${attr}="#${existing}"`
}
}
Expand Down