Skip to content

Commit 77a0ec2

Browse files
committed
* prevent setting site.name with @ undefined suffix when env NUXT_PUBLIC_INSTANCE_NAME is unset
* disable `robots.robotsTxt` to fix `You are not allowed to generate a robots.txt with a base URL` * update `compatibilityDate` @ nuxt.config.ts * migrate or disable all deprecated rules @ eslint.config.js * fix typing of the value being passed to `referrerpolicy` attr of every `<img>` @ components/post/renderer/Content.vue * fix invoking `createSitePathResolver()` outside nuxt context while rehydrating @ utils/post/seo/schemaOrg.ts @ fe
1 parent 9c5cd07 commit 77a0ec2

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

fe/eslint.config.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ const rules = [{ // as of eslint-plugin-unicorn@50.0.1
176176

177177
// https://github.com/eslint-stylistic/eslint-stylistic/issues/249
178178
// '@stylistic/type-annotation-spacing': 'error',
179+
'@stylistic/multiline-comment-style': ['error', 'separate-lines'],
179180
},
180181
}, { // as of eslint@8.56.0
181182
optout: {
@@ -238,7 +239,6 @@ const rules = [{ // as of eslint-plugin-unicorn@50.0.1
238239
'capitalized-comments': ['error', 'never'],
239240
'consistent-this': 'error',
240241
'func-name-matching': 'error',
241-
'multiline-comment-style': ['error', 'separate-lines'],
242242
'new-cap': 'error',
243243

244244
// 'newline-per-chained-call': ['error', { 'ignoreChainWithDepth': 3 }],
@@ -258,7 +258,6 @@ const rules = [{ // as of eslint-plugin-unicorn@50.0.1
258258

259259
// 'sort-keys': ['error', 'asc', { 'caseSensitive': false, 'natural': true }],
260260
'sort-vars': ['error', { ignoreCase: true }],
261-
'no-new-symbol': 'error',
262261
'no-useless-computed-key': ['error', { enforceForClassMembers: true }],
263262
'no-useless-rename': 'error',
264263
'no-var': 'error',
@@ -293,8 +292,6 @@ const rules = [{ // as of eslint-plugin-unicorn@50.0.1
293292
'@typescript-eslint/no-invalid-this': 'error',
294293
'no-loop-func': 'off',
295294
'@typescript-eslint/no-loop-func': 'error',
296-
'no-loss-of-precision': 'off',
297-
'@typescript-eslint/no-loss-of-precision': 'error',
298295
'no-redeclare': 'off',
299296
'@typescript-eslint/no-redeclare': 'error',
300297

@@ -307,7 +304,6 @@ const rules = [{ // as of eslint-plugin-unicorn@50.0.1
307304
'@typescript-eslint/no-use-before-define': 'error',
308305
'no-useless-constructor': 'off',
309306
'@typescript-eslint/no-useless-constructor': 'error',
310-
'no-return-await': 'off',
311307
'@typescript-eslint/return-await': 'error',
312308
'require-await': 'off',
313309
'@typescript-eslint/require-await': 'error',
@@ -381,7 +377,6 @@ const rules = [{ // as of eslint-plugin-unicorn@50.0.1
381377
'@typescript-eslint/prefer-readonly': 'error',
382378
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
383379
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
384-
'@typescript-eslint/prefer-ts-expect-error': 'error',
385380
'@typescript-eslint/promise-function-async': 'error',
386381
'@typescript-eslint/require-array-sort-compare': 'error',
387382
'@typescript-eslint/strict-boolean-expressions': 'error',
@@ -447,7 +442,6 @@ const rules = [{ // as of eslint-plugin-unicorn@50.0.1
447442
'vue/html-comment-indent': ['error', 4],
448443
'vue/no-duplicate-attr-inheritance': 'error',
449444
'vue/no-empty-component-block': 'error',
450-
'vue/no-invalid-model-keys': 'error',
451445
'vue/no-multiple-objects-in-class': 'error',
452446

453447
// https://github.com/nuxt/nuxt/issues/15015

fe/nuxt.config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { keysWithSameValue } from './src/utils';
33
import { analyzer } from 'vite-bundle-analyzer';
44

55
export default defineNuxtConfig({
6-
compatibilityDate: '2024-07-04',
6+
compatibilityDate: '2025-04-24',
77
devServer: { https: true },
8-
devtools: { enabled: false },
98
srcDir: 'src',
109
imports: { dirs: ['api/**', 'utils/**'] },
1110
modules: [
@@ -31,9 +30,14 @@ export default defineNuxtConfig({
3130
}
3231
},
3332
site: {
34-
name: `open-tbm @ ${process.env.NUXT_PUBLIC_INSTANCE_NAME}`,
33+
name: `open-tbm${
34+
process.env.NUXT_PUBLIC_INSTANCE_NAME === undefined
35+
? ''
36+
: ` @ ${process.env.NUXT_PUBLIC_INSTANCE_NAME}`
37+
}`,
3538
defaultLocale: 'zh'
3639
},
40+
robots: { robotsTxt: false }, // https://github.com/nuxt-modules/robots/commit/c8958975b09d0e9aa3651505d023be43b0da4ec2
3741
sitemap: {
3842
sitemaps: true,
3943
appendSitemaps: [{ sitemap: `${process.env.NUXT_PUBLIC_BE_URL}/sitemaps/forums` }]

fe/src/components/post/renderer/Content.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
:to="src" target="_blank" class="tieba-ugc-image">
88
<!-- eslint-disable-next-line vue/no-duplicate-attr-inheritance -->
99
<img
10-
:src="src" :referrerpolicy="config.tiebaImageReferrerPolicy"
10+
:src="src" :referrerpolicy="tiebaImageReferrerPolicy"
1111
loading="lazy" class="tieba-ugc-image" v-bind="attrs" />
1212
</NuxtLink>
1313
<!-- eslint-disable-next-line vue/no-duplicate-attr-inheritance -->
1414
<img
15-
v-else :src="src" :referrerpolicy="config.tiebaImageReferrerPolicy"
15+
v-else :src="src" :referrerpolicy="tiebaImageReferrerPolicy"
1616
loading="lazy" class="tieba-ugc-image" v-bind="attrs" />
1717
</DefineUGCImage>
1818
<div v-for="(i, index) in content" :key="index" class="post-content-item">
@@ -24,7 +24,7 @@
2424
</NuxtLink>
2525
<img
2626
v-if="i.type === 2" :src="emoticonUrl(i.text)" :alt="i.c"
27-
:referrerpolicy="config.tiebaImageReferrerPolicy" loading="lazy" />
27+
:referrerpolicy="tiebaImageReferrerPolicy" loading="lazy" />
2828
<ReuseUGCImage v-if="i.type === 3" :src="imageUrl(i.originSrc)" />
2929
<NuxtLink
3030
v-if="i.type === 4"
@@ -52,7 +52,7 @@
5252
</span>
5353
<img
5454
v-if="i.type === 11" :src="toHTTPS(i.dynamic)" :alt="i.c"
55-
:referrerpolicy="config.tiebaImageReferrerPolicy" loading="lazy" class="d-block" />
55+
:referrerpolicy="tiebaImageReferrerPolicy" loading="lazy" class="d-block" />
5656
<ReuseUGCImage v-if="i.type === 16" :src="toHTTPS(i.graffitiInfo?.url)" alt="贴吧涂鸦" />
5757
<NuxtLink v-if="i.type === 20" :to="i.memeInfo?.detailLink" target="_blank">
5858
<ReuseUGCImage v-if="i.type === 20" :src="toHTTPS(i.src)" />
@@ -62,10 +62,12 @@
6262
</template>
6363

6464
<script setup lang="ts">
65+
import type { ImgHTMLAttributes } from 'vue';
6566
import _ from 'lodash';
6667
6768
defineProps<{ content: PostContent | null }>();
68-
const config = useRuntimeConfig().public;
69+
const tiebaImageReferrerPolicy = undefinedWhenEmpty(useRuntimeConfig().public
70+
.tiebaImageReferrerPolicy as ImgHTMLAttributes['referrerpolicy']);
6971
const [DefineUGCImage, ReuseUGCImage] = createReusableTemplate<{ src?: string }>({ inheritAttrs: false });
7072
useViewerStore().enable();
7173
</script>

fe/src/stores/viewer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-disable-next-line import-x/no-unresolved
21
import viewer from 'v-viewer';
32
import 'viewerjs/dist/viewer.css';
43

fe/src/utils/post/seo/schemaOrg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import type { InfiniteData } from '@tanstack/vue-query';
33
import { DateTime } from 'luxon';
44

55
type PartialPostPageProvision = Pick<PostPageProvision, 'getUser'>;
6-
const resolvePath = createSitePathResolver({ withBase: true });
76

87
// https://developers.google.com/search/docs/appearance/structured-data/discussion-forum
98
export const usePostsSchemaOrg = (data: Ref<InfiniteData<ApiPosts['response']> | undefined>) => {
109
const router = useRouter();
10+
const resolvePath = createSitePathResolver({ withBase: true });
1111
const definePostComment = <T extends Post>(post: T, postIDKey: keyof T & PostIDOf<T>): Comment => ({
1212
/* eslint-disable @typescript-eslint/naming-convention */
1313
'@type': 'Comment',

0 commit comments

Comments
 (0)