Skip to content

Commit 542cd9e

Browse files
atinuxfarnabaz
andauthored
fix: add article id to handle on Studio (#134)
* feat: add `data-content-id` to articles in preview mode * chore: upgrade deps * fix: disable inlineSSRStyles for now --------- Co-authored-by: Farnabaz <farnabaz@gmail.com>
1 parent 0335844 commit 542cd9e

4 files changed

Lines changed: 1378 additions & 1424 deletions

File tree

components/content/ArticlesListItem.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<script setup lang="ts">
2+
import { useContentPreview } from '#imports'
3+
24
type Article = {
35
_path: string
46
title: string
57
date: string
68
description: string
79
}
810
9-
defineProps({
11+
const props = defineProps({
1012
article: {
1113
type: Object,
1214
required: true,
@@ -20,10 +22,15 @@ defineProps({
2022
default: false
2123
}
2224
})
25+
26+
const id = computed(() => {
27+
// @ts-ignore
28+
return (process.dev || useContentPreview()?.isEnabled()) ? props.article?._id : undefined
29+
})
2330
</script>
2431

2532
<template>
26-
<article v-if="article._path && article.title" :class="{ 'featured': featured }">
33+
<article v-if="article._path && article.title" :class="{ 'featured': featured }" :data-content-id="id">
2734
<div class="image">
2835
<NuxtLink :to="article._path">
2936
<NuxtImg v-if="article.cover" :src="article.cover" :alt="article.title" width="16" height="9" />

nuxt.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,8 @@ export default defineNuxtConfig({
4848
},
4949
preload: ['json', 'js', 'ts', 'html', 'css', 'vue', 'diff', 'shell', 'markdown', 'yaml', 'bash', 'ini', 'c', 'cpp']
5050
}
51+
},
52+
experimental: {
53+
inlineSSRStyles: false
5154
}
5255
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@nuxt/eslint-config": "^0.1.1",
3939
"@nuxtjs/plausible": "^0.2.1",
4040
"eslint": "^8.40.0",
41-
"nuxt": "3.4.2",
41+
"nuxt": "^3.4.3",
4242
"release-it": "^15.10.3",
4343
"typescript": "^5.0.4",
4444
"vue": "^3.2.47"

0 commit comments

Comments
 (0)