Skip to content

Commit

Permalink
fix: markdown-it and add ci node_modules cache
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Jan 30, 2024
1 parent abef4fe commit a4f1ee0
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 59 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,31 @@ jobs:
uses: actions/checkout@v3
with:
submodules: 'true'

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list

- name: Install Dependencies
run: npm ci --registry=https://registry.npmjs.org

- run: npm run build:cdn
99 changes: 42 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"katex": "^0.16.9",
"lodash": "^4.17.11",
"lodash.throttle": "^4.1.1",
"markdown-it": "^14.0.0",
"markdown-it": "^13.0.2",
"math-precision": "^1.0.5",
"md5": "^2.2.1",
"memoize-one": "^5.1.1",
Expand Down
14 changes: 13 additions & 1 deletion src/pages/competitions-public/$id/participants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ import { genshinCharacters } from '@/configs/genshin';
import markdownit from 'markdown-it';

const md = markdownit().disable('image');
// Remember the old renderer if overridden, or proxy to the default renderer.
const defaultRender = md.renderer.rules.link_open || function (tokens, idx, options, env, self) {
return self.renderToken(tokens, idx, options);
};

md.renderer.rules.link_open = function (tokens, idx, options, env, self) {
// Add a new `target` attribute, or replace the value of the existing one.
tokens[idx].attrSet('target', '_blank');

// Pass the token to the default renderer.
return defaultRender(tokens, idx, options, env, self);
};

export interface Props extends ReduxProps, RouteProps {
id: number;
Expand Down Expand Up @@ -130,7 +142,7 @@ class CompetitionParticipants extends React.Component<Props, State> {
);
};

renderSlogan = (slogan: string) => {
renderSlogan = (slogan = '') => {
const result = md.renderInline(slogan);
return (
<p
Expand Down

0 comments on commit a4f1ee0

Please sign in to comment.