Skip to content
Merged
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
184 changes: 92 additions & 92 deletions blog-website/api/package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions blog-website/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"@types/jest": "^30.0.0",
"@types/lodash": "^4.17.24",
"@types/node": "^24.0.0",
"@typescript-eslint/eslint-plugin": "^8.57.0",
"@typescript-eslint/parser": "^8.57.0",
"@typescript-eslint/eslint-plugin": "^8.58.0",
"@typescript-eslint/parser": "^8.58.0",
"eslint": "^10.0.0",
"jest": "^30.0.0",
"ts-jest": "^29.4.6",
"typescript": "^5.9.3",
"typescript-eslint": "^8.57.0"
"ts-jest": "^29.4.9",
"typescript": "^6.0.0",
"typescript-eslint": "^8.58.0"
},
"main": "dist/src/main.js"
}
3 changes: 1 addition & 2 deletions blog-website/api/src/functions/fallback/redirect.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import type { InvocationContext } from '@azure/functions';
import { describe, expect, test } from '@jest/globals';
import { describe, expect, jest, test } from '@jest/globals';

import { redirect } from './redirect.js';

Expand Down
3 changes: 2 additions & 1 deletion blog-website/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
"noErrorTruncation": true,
"ignoreDeprecations": "6.0",

/* Language and Environment */
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
Expand All @@ -35,7 +36,7 @@
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
"types": ["node"], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "resolveJsonModule": true, /* Enable importing .json files. */
Expand Down
1 change: 1 addition & 0 deletions blog-website/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default [
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/parameter-properties': 'off',
'@typescript-eslint/typedef': 'off',
'@eslint-react/dom-no-dangerously-set-innerhtml': 'off',
},
},
];
29 changes: 18 additions & 11 deletions blog-website/image-fetchpriority-rehype-plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export default function imageFetchPriorityRehypePluginFactory() {
/** @type {import('unified').Transformer} */
return (tree, vfile) => {
visit(tree, ['mdxJsxTextElement'], (node) => {
if (node.type === 'mdxJsxTextElement' && node['name'] === 'img') {
const mdxJsxNode =
/** @type {import('mdast-util-mdx-jsx').MdxJsxTextElement} */ (node);
/** @type {import('mdast-util-mdx-jsx').MdxJsxAttribute[]} */
const attrs = /** @type {any} */ (mdxJsxNode.attributes);
if (mdxJsxNode.type === 'mdxJsxTextElement' && mdxJsxNode.name === 'img') {
// handles nodes like this:
// {
// type: 'mdxJsxTextElement',
Expand All @@ -37,10 +41,13 @@ export default function imageFetchPriorityRehypePluginFactory() {
// children: []
// }

const srcIndex = node['attributes'].findIndex(
const srcIndex = attrs.findIndex(
(attr) => attr.name === 'src',
);
const requireString = node['attributes'][srcIndex].value.value;
const requireString =
/** @type {import('mdast-util-mdx-jsx').MdxJsxAttributeValueExpression} */ (
attrs[srcIndex].value
).value;

const key = `jsx|${vfile.history[0]}`;
const imageAlreadyProcessed = files.get(key);
Expand All @@ -52,39 +59,39 @@ export default function imageFetchPriorityRehypePluginFactory() {
}

// expect to be -1
const loadingIndex = node['attributes'].findIndex(
const loadingIndex = attrs.findIndex(
(attr) => attr.name === 'loading',
);

if (fetchpriorityThisImage) {
// expect to be -1
const fetchpriorityIndex = node['attributes'].findIndex(
const fetchpriorityIndex = attrs.findIndex(
(attr) => attr.name === 'fetchpriority',
);
if (loadingIndex > -1) {
node['attributes'][loadingIndex].value = 'eager';
attrs[loadingIndex].value = 'eager';
} else {
node['attributes'].push({
attrs.push({
type: 'mdxJsxAttribute',
name: 'loading',
value: 'eager',
});
}

if (fetchpriorityIndex > -1) {
node['attributes'][fetchpriorityIndex].value = 'high';
attrs[fetchpriorityIndex].value = 'high';
} else {
node['attributes'].push({
attrs.push({
type: 'mdxJsxAttribute',
name: 'fetchpriority',
value: 'high',
});
}
} else {
if (loadingIndex > -1) {
node['attributes'][loadingIndex].value = 'lazy';
attrs[loadingIndex].value = 'lazy';
} else {
node['attributes'].push({
attrs.push({
type: 'mdxJsxAttribute',
name: 'loading',
value: 'lazy',
Expand Down
Loading
Loading